Debug console PHP applications with NetBeans

Assuming you already have PHP and NetBeans configured to debug code using XDebug, these are the steps to debug a console PHP application:

In the terminal window export the value of the XDEBUG_SESSION_START get parameter that NetBeans adds when starting a debug session on the web brower. It’s usually netbeans-xdebug so you should run this for GNU/Linux or Mac OS X:

$ export XDEBUG_CONFIG="idekey=netbeans-xdebug"

And this for Windows (notice the lack of quotes):

C:> export XDEBUG_CONFIG=idekey=netbeans-xdebug

You can change the XDEBUG_SESSION_START value inside PHP NetBeans options in the Debugging tab:

configure netbeans debugging options

Then inside NetBeans set any line you want as a stop point and start the debugger as usual pushing the debug button:

netbeans debug button

Your web broser should open a new tab with the current web being developed. Now in the terminal window that you exported the XDEBUG_CONFIG variable run the php file you want:

$ php my_php_file.php

The debugging process should start and you’ll be ready to go:

debugging

Ref: http://stackoverflow.com/questions/2944880/debugging-php-cli-scripts-with-xdebug-and-netbeans

You might also like

No splash screen on NetBeans
I'm not a fan of the splash screens the applications, even less on those that place it on top of all...

Install and activate xdebug in MacPorts
First install php5-xdebug:sudo port install php5-xdebugThen just add these in your php.ini (probably...

Fix Netbeans fonts after installing Wine
As I wasn't going to use Wine that much and broking my fonts pissed me off I decided to completelly uninstall...

Fix Netbeans fonts after installing Wine
As I wasn't going to use Wine that much and broking my fonts pissed me off I decided to completelly uninstall...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.