Bee*_*ice 5 php xdebug phpstorm xdebug-profiler
我很难将xdebug性能分析工作并整合到2017年的PhpStorm中.我试图关注此视频但没有成功.
我知道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
Run Code Online (Sandbox Code Playgroud)
在PHP执行开始时,我试图打开这样的分析:
ini_set('xdebug.profiler_enable','1');
Run Code Online (Sandbox Code Playgroud)
我还尝试使用以下命令从命令行运行脚本:
php script.php -d xdebug.profiler_enable=1
Run Code Online (Sandbox Code Playgroud)
没有错误提出.C:\websites\tmp两者中都没有创建文件.
我遇到了最简单的Xdebug扩展,但如果可以避免的话,我宁愿不依赖于另一个软件(我甚至没有尝试过它以确定它是否可行).
我了解了xdebug.remote_logini指令并将其设置为一个文件,然后重新启动了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>
Run Code Online (Sandbox Code Playgroud)
正如我所说,调试工作正常.现在,如果不监听调试但尝试使用命令行参数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
Run Code Online (Sandbox Code Playgroud)
我只能生成探查器的cachegrind.out文件!我不知道确切的限制,使这项工作还没有,但我所做的是取消对xdebug.profiler_enable行我的php.ini以上并重新启动Apache的.我仍然需要一种方法来仅按需启用分析器,就像我在顶部链接的视频一样.在php.ini中始终使用它会增加太多开销,因为大多数时候我不需要分析器数据
这是我的工作解决方案:
php.ini
[Xdebug]
zend_extension=php_xdebug-2.6.0-7.2-vc15.dll
xdebug.default_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
Run Code Online (Sandbox Code Playgroud)
httpd.conf:
Listen 127.0.0.1:80
Run Code Online (Sandbox Code Playgroud)