我很难让 xdebug 分析工作并集成到 PhpStorm 2017。我试图跟随这个视频但没有成功。
我知道 xdebug 已正确安装在 Web 服务器上(Windows 上的本地 Apache 安装)并正确集成到 PhpStorm 中,因为当我在 IDE 中单击“开始侦听 PHP 调试连接”时,我的断点会停止代码执行,我只能调试美好的。我只是无法让探查器生成它的文件,我什至不知道它是否正在运行。
php.ini
<!-- language: lang-none -->
[xdebug]
zend_extension="php_xdebug-2.5.5-5.6-vc11.dll"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
; xdebug.profiler_enable=1 ; I've tried uncommenting. Made no difference
; xdebug.profiler_enable_trigger=1 ; I've tried uncommenting. Made no difference
xdebug.profiler_output_dir="C:\websites\tmp"
xdebug.profiler_output_name="cachegrind.out.%p"
xdebug.idekey=PHPSTORM
在我的 PHP 执行开始时,我尝试像这样打开分析:
ini_set('xdebug.profiler_enable','1');
我还尝试使用以下命令从命令行运行脚本:
php script.php -d xdebug.profiler_enable=1
不会引发错误。也没有创建文件C:\websites\tmp
。
我遇到了最简单的 Xdebug扩展,但如果可以避免的话,我宁愿不依赖其他软件(而且我什至没有尝试过它是否可以工作)。
- PHP 5.6
- 阿帕奇 2.4
- xdebug 2.5.5
- 2017 年 PHP 风暴
- 视窗 7 64 位
更新
我了解了xdebug.remote_log
ini 指令并将其设置为一个文件,然后重新启动了 Apache。这是我在运行正常调试会话时在日志中看到的内容(意味着我在 PhpStorm 中单击“开始侦听 PHP 调试连接” ):
<!-- language: lang-none -->
Log opened at 2017-07-22 20:33:03
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
fileuri="file:///C:/path/to/script.php"...>
</init>
正如我所说,调试工作正常。现在,如果不监听调试但尝试使用命令行参数php script.php -d xdebug.profiler_enable=1
或在脚本中启用探查器ini_set('xdebug.profiler_enable','1')
,这就是 xdebug 日志显示的内容
<!-- language: lang-none -->
Log opened at 2017-07-22 20:38:10
I: Connecting to configured address/port: localhost:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-07-22 20:38:11
更新 2
我只是能够生成探查器的cachegrind.out文件!我还不知道完成这项工作的确切限制,但我所做的是取消注释上面的php.inixdebug.profiler_enable
行并重新启动 Apache。我仍然需要一种方法来按需启用分析器,就像我在顶部链接的视频中那样。在php.ini中始终打开它会增加太多开销,因为大多数时候我不需要分析器数据