XDebug profiling not working in windows command line

970 Views Asked by At

I'm struggling with xDebug profiling in WAMP. It works perfectly with browsers, I'm getting cachegrind.out files, but no luck if I try to execute a php script with command line. No cachegrind files are being generated.

Here is my php.ini file:

[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp/profiler"

I have also tried with profiler_enable_trigger = 0. AlsoTried adding parameters:

php -d xdebug.profiler_enable=On script.php

and

php -dxdebug.profiler_enable=On script.php

Like described in This SO question

I even performed php --ini to know if on windows there was another php.ini file different from the one Apache used. It turns out that is the very same file:

Configuration File (php.ini) Path: C:\windows
Loaded Configuration File:         C:\wamp\bin\php\php5.4.12\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Since it's the same php.ini, I'm running out of ideas. Could you help me? If you need any other output, don't hesitate.

1

There are 1 best solutions below

1
On

If you turn xdebug.profiler_enable_trigger on, then you need to set a cookie to trigger the profiler. As you can not set cookies on the command line, this won't work. For command line profiling, you need to have:

xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0

There is an issue at http://bugs.xdebug.org/view.php?id=1005 to add environment variable based triggers as well.