Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging php-cli scripts with xdebug and netbeans?

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 maintenance PHP scripts which take a lot of input parameters, so entering arguments from within Netbeans is a bit cumbersome.

I have done it before with Zend studio: https://zend18.zendesk.com/hc/en-us/articles/203838096-Debugging-PHP-CLI-Scripts, but now I need to get it working with Netbeans.

Thanks in advance.

like image 671
wurdalack Avatar asked May 31 '10 16:05

wurdalack


People also ask

How do I debug in NetBeans?

Taking a GUI Snapshot or, click the Debug button in the toolbar to start the debugging session. Alternatively, right-click the project node in the Projects window and choose Debug. When you start the session, the IDE will launch the Anagram Game application and open the Debugging window.


1 Answers

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) so 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.

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.

like image 115
Andrew Hancox Avatar answered Oct 26 '22 20:10

Andrew Hancox