【问题标题】:PhpStorm and xdebug profiler setup on Windows localhostWindows localhost 上的 PhpStorm 和 xdebug 分析器设置
【发布时间】:2017-12-28 17:52:44
【问题描述】:

我很难让 xdebug 分析工作并集成到 PhpStorm 2017。我尝试关注this video,但没有成功。

我知道 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也没有创建文件。

我遇到了easiest Xdebug 扩展,但如果可以避免它,我宁愿不依赖其他软件(而且我什至没有尝试过它是否可以工作)。

  • PHP 5.6
  • Apache 2.4
  • xdebug 2.5.5
  • PhpStorm 2017
  • Windows 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 中始终打开它会增加太多开销,因为大多数时候我不需要分析器数据

【问题讨论】:

  • “我仍然需要一种方法来仅按需启用分析器” xdebug.profiler_enable_trigger=1 + 浏览器扩展(或手动向 URL 添加参数)就可以了。到目前为止,这只是关于 xdebug 配置,与 PhpStorm 无关。
  • @LazyOne 好的,所以我用xdebug.profiler_enable_trigger=1 启用触发器,然后我删除xdebug.profiler_enable 对吗?至于 URL 参数,你知道触发分析是什么吗?感谢您的信息。
  • xdebug.org/docs/profiler -- 所有信息都在那里 -- XDEBUG_PROFILE

标签: php phpstorm xdebug xdebug-profiler


【解决方案1】:

这是我的工作解决方案:

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

httpd.conf:

Listen 127.0.0.1:80

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-29
    • 2013-07-28
    • 2021-08-28
    • 2015-07-04
    • 1970-01-01
    • 2016-09-25
    • 1970-01-01
    相关资源
    最近更新 更多