作者:佳人蔚虹的小资心情_396 | 来源:互联网 | 2023-01-28 18:53
我很难将xdebug性能分析工作并整合到2017年的PhpStorm中.我试图关注此视频但没有成功.
我知道xdebug已正确安装在Web服务器上(Windows安装上的本地Apache)并正确集成到PhpStorm中,因为当我在IDE中单击"开始侦听PHP调试连接"时,我的断点会停止代码执行,我可以调试精细.我只是无法让探查器生成其文件,我甚至不知道它是否正在运行.
php.ini中
[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
Apache 2.4
xdebug 2.5.5
PhpStorm 2017
Windows 7 64位
更新
我了解了xdebug.remote_log
ini指令并将其设置为一个文件,然后重新启动了Apache.这是我在日志中看到的,当我运行正常的调试会话时(意味着我点击了PhpStorm中的"开始收听PHP调试连接"):
Log opened at 2017-07-22 20:33:03
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
->
正如我所说,调试工作正常.现在,如果不监听调试但尝试使用命令行参数php script.php -d xdebug.profiler_enable=1
或在脚本中启用探查器ini_set('xdebug.profiler_enable','1')
,这就是xdebug日志显示的内容
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文件!我不知道确切的限制,使这项工作还没有,但我所做的是取消对xdebug.profiler_enable
行我的php.ini以上并重新启动Apache的.我仍然需要一种方法来仅按需启用分析器,就像我在顶部链接的视频一样.在php.ini中始终使用它会增加太多开销,因为大多数时候我不需要分析器数据