How to trigger XDebug profiler for a command line PHP script?
You can pass INI settings with the -d
flag: php -d xdebug.profiler_enable=On script.php
.
I got this working on Ubuntu/Netbeans by:
- copying the xdebug config lines from the /etc/php5/apache2/php.ini file into /etc/php5/cli/php.ini
- setting an environment variable with the name of the debug session (you can get this from the query string in the url of the page netbeans launches when you start debugging) the command is: export XDEBUG_CONFIG="idekey=netbeans-xdebug"
Then it's simply a case of starting debugging in netbeans and doing "php myscript.php" at the command line.
with PhpStorm on remote webserver i use this command:
XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName=server_name" php -dxdebug.remote_host=`echo $SSH_CLIENT | cut -d "=" -f 2 | awk '{print $1}'` myscript.php
where server_name
stands for name of the server in PhpStorm project conifuguration