IntelliJ,PhpStorm:使用xdebug进行调试会忽略XDEBUG_SESSION cookie

lan*_*oxx 10 php xdebug intellij-idea phpstorm

我正在尝试使用Intellij中的PHP插件调试Drupal网站(在PhpStorm中也是如此).

我有以下设置:

Chrome浏览器指向localhost别名,mydomain.local并安装XDebug Helper扩展并设置为Debug.在Cookies下的开发人员工具中,我可以看到XDEBUG_SESSIONcookie设置为PHPSTORM.

我使用以下设置使用xdebug插件配置了php:

xdebug.extended_info = 1
xdebug.idekey = "PHPSTORM"
xdebug.max_nesting_level = 500
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_mode = req
xdebug.remote_port = 9000
Run Code Online (Sandbox Code Playgroud)

在IntelliJ中,我设置了一个服务器指向mydomain.local并在运行配置中我正在使用该服务器并将Ide键设置为PHPSTORM.

现在的问题是:

如果我在PHP脚本的第一行启用Break,那么调试器会立即在第一个可破坏的位置中断index.php.如果我禁用该选项,我会收到一个警告,即没有命中断点,即使我设置了断点并且我确定代码正在执行.我看到的警告看起来像这样:

Debug session was finished without being paused
It may be caused by path mappings misconfiguration or not synchronized
local and remote projects.
To figure out the problem check path mappings configuration for 
'mydomain.local' server at PHP|Servers or enable Break at first line in
PHP scripts option (from Run menu).
Run Code Online (Sandbox Code Playgroud)

现在,如果我明确使用附加了以下查询参数的URL:?XDEBUG_SESSION_START=PHPSTORM那么我的所有断点都在IntelliJ中被正确分解.

问题:为什么XDEBUG_SESSION忽略cookie?

更新:添加了我的PHP和XDebug版本输出php -v:

PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016,
    by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)

和我的Apache虚拟主机配置:

<VirtualHost *:80>
    DocumentRoot /var/www/html/mydomain
    ServerName mydomain.local
    <Directory /var/www/html/mydomain>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/mydomain.log
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

更新2: 我安装了一个名为的php扩展程序fpm.我不太清楚为什么安装或者我需要它.我认为它是用PHP自动安装的.这会干扰吗?

Att*_*lop 5

当我" 过度配置 "我的设置时,我曾经遇到过这个问题.

  1. 您可能想尝试将XDebug辅助扩展添加到chrome
  2. 添加之后转到插件的设置并选择PhpStorm:

XDebug助手设置

  1. 尝试仅将xdebug配置拆分为这些值:

(在我的盒子上工作)

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
Run Code Online (Sandbox Code Playgroud)
  1. PhpStorm配置应包含调试端口9000和[X]可以接受外部连接:

PhpStorm Xdebug设置

  1. 然后你应该在PhpStorm上监听调试连接:

PhpStorm调试听力

  1. 还可以在浏览器中启用调试(通过xdebug帮助程序):

Xdebug帮助器调试

  1. 如果错误图标为绿色 xdebug帮助器调试,如果你刷新页面,你应该很高兴,PhpStorm应该停在第一个断点.


lan*_*oxx 0

事实证明,问题不在于 IntelliJ 或 PhpStorm,而在于 Drupal 特定的问题。特别是我需要禁用所有缓存。

在开发过程中禁用 Drupal 8 缓存一文详细解释了执行此操作的步骤。

在我禁用 Drupal 缓存后,一切都按预期工作。