1

==================================================== =======

忽略此帖。可以在PHP auto_prepend_file 中找到关于此问题的更简单的说明,导致 xdebug 分析器失败

==================================================== =======

原始帖子(和更新)

当我尝试使用以下命令在 PhpStorm 中打开 xdebug 分析器快照时:

菜单栏 >> 工具 >> 分析 xdebug profiler 快照...

我选择了创建的文件 xDebug,但我遇到了这个错误:

错误:探查器快照格式不正确:名称格式不正确

我没有重命名快照。它是默认名称:cachegrind.out.8008

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
xdebug.profiler_output_dir="C:\websites\xdebug"
; xdebug.profiler_output_name= ; Commented out to allow default name
xdebug.idekey=PHPSTORM

为什么 PhpStorm 不会打开快照?我应该设置自定义xdebug.profiler_output_name选项吗?

更新

我关闭了所有项目,从 PhpStorm 升级2017.1.42017.2,重新启动 Apache,删除了旧快照并创建了一个新快照。 新的打开没有麻烦。

更新 2

似乎如果我通过调用从命令行运行文件,>php script.php则可以打开生成的快照。如果我从浏览器运行相同的文件(意味着我通过 Apache 网络服务器:)localhost/script.php,则无法打开快照。

更新 3

我还注意到,当我从浏览器执行时,我无法删除快照,直到我强制停止 Apache 进程。我正在分析的 PHP 文件没有说明:只是<?php. 以下是创建的两个快照:

从命令行执行时(PhpStorm 打开此文件没有问题):

version: 1
creator: xdebug 2.5.5 (PHP 5.6.1-dev)
cmd: C:\path\to\script.php
part: 1
positions: line

events: Time

fl=(1) C:\path\to\script.php
fn=(1) {main}

summary: 0

1 0

从浏览器执行时(PhpStorm 无法打开此快照):

version: 1
creator: xdebug 2.5.5 (PHP 5.6.1-dev)
cmd: C:\path\to\script.php
part: 1
positions: line

events: Time

fl=(2) C:\path\to\script.php
fn=(1)

summary: 0

1 0

更新 4

罪魁祸首是auto_prepend_fileini设置。我在 Apache Vhosts 中有以下设置:

php_value auto_prepend_file "C:\path\to\init.php"

该文件在 Apache 执行从浏览器调用的脚本之前运行。当我从命令行运行脚本时,此设置(在我的 Apache Vhosts 配置中)永远不会生效,因此init.php不会运行。相反,如果我将设置移动到php.ini它也会影响命令行执行的位置,那么从命令行生成的快照也会停止工作。

如果我删除该auto_prepend_file设置,生成的分析器快照可以在 PhpStorm 中毫无问题地打开。当然这不是一个修复,因为我需要auto_prepend_file执行才能让我的应用程序正常工作。

4

0 回答 0