PhpStorm won't open xdebug profiler snapshot file

末鹿安然 提交于 2019-12-11 07:08:50

问题


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

Ignore this post. A much simpler statement of this issue can be found at PHP auto_prepend_file causes xdebug profiler to fail

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

Original Post (and updates)

When I try to open an xdebug profiler snapshot within PhpStorm using:

menu bar >> Tools >> Analyze xdebug profiler snapshot...

I select the file xDebug created but I'm faced with this error:

Error: Incorrect profiler snapshot format: Incorrect name format

I did not rename the snapshot. It is the default name: 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

Why won't PhpStorm open the snapshot? Should I set a custom xdebug.profiler_output_name option?

Update

I closed all my projects, upgraded from PhpStorm 2017.1.4 to 2017.2, restarted Apache, deleted the old snapshots and created a new one. The new one opens without trouble.

Update 2

Seems that if I run a file from the command line by calling >php script.php, the generated snapshot can be opened. If I run the same file from the browser (meaning I go through the Apache webserver: localhost/script.php) the snapshot cannot be opened.

Update 3

I also notice that when I execute from the browser, I can't delete the snapshot until I force-stop the Apache process. The PHP file I'm profiling has no instructions: just <?php. Below are the two snapshots created:

When executed from the command line (PhpStorm opens this file without problem):

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

When executed from the browser (PhpStorm cannot open this snapshot):

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

Update 4

The culprit is the auto_prepend_file ini setting. I had the following set in Apache Vhosts:

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

This file is run before Apache executes the script that was called from the browser. When I run the script from the command line, this setting (which is in my Apache Vhosts config) never takes effect so init.php doesn't run. Conversely, if I move the setting to php.ini where it also affects command-line execution, then snapshots generated from the command-line also stop working.

If I remove the auto_prepend_file setting, the generated profiler snapshot can be open without problem in PhpStorm. Of course this isn't a fix since I need the auto_prepend_file to execute for my application to work properly.

来源:https://stackoverflow.com/questions/45259259/phpstorm-wont-open-xdebug-profiler-snapshot-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!