gpt4 book ai didi

Windows 本地主机上的 PhpStorm 和 xdebug 探查器设置

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:49:16 24 4
gpt4 key购买 nike

我很难让 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。这是我在运行正常调试 session 时在日志中看到的内容(意思是我在 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 中始终启用它会增加太多开销,因为大多数时候我不需要分析器数据

最佳答案

这是我的工作解决方案:

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

enter image description here

enter image description here

enter image description here

关于Windows 本地主机上的 PhpStorm 和 xdebug 探查器设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45258658/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com