I have managed to initiate php-cli script debug session from the IDE itself, but I need to start the debugging session from the shell / command line. These are rather complex ma
Add xdebug.remote_autostart=On
to your php.ini file or add -dxdebug.remote_autostart=On
as parameter to the PHP binary call (php -d... script.php
).
See http://xdebug.org/docs/remote
Make sure you also setup DBGP_IDEKEY value, because usually it is not idekey. For example on Linux:
export DBGP_IDEKEY="netbeans-xdebug"
export XDEBUG_CONFIG="netbeans-xdebug=netbeans-xdebug"
I got this working on Ubuntu/Netbeans by:
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.
Note: If you want to debug remotely using netbeans you need to use Debug File on the file that is being run from the command line, not normal Debug.
I had the same problem, my solution was this:
You can use the Dephpugger project if you dont want to configure xDebug for your IDE (i hate configurations).
https://github.com/tacnoman/dephpugger
You can run the debugger in terminal, like ipdb for Python and byebug for Ruby.
I will put all together, the following is that works for me.
file:
/etc/php5/cli/php.ini
zend_extension="/usr/lib/php5/20121212/xdebug.so" -> xdebug bin path
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9000 -> same port configured in netbeans debugging tab
xdebug.idekey="netbeans-xdebug" -> same ide configured in netbeans debuggin tab
xdebug.remote_autostart=1
then, without any other parameter
php script.php