NetBeans 7.0 for PHP Waiting for Connection to XDebug

NetBeans IDE 7.0 for PHP and XDebug

NetBeans IDE 7.0 for PHP and XDebug


Recently I met with one annoying thing during work on the small PHP programming task. My favorite IDE for PHP development NetBeans failed to connect to the PHP debug library xDebug. It just shows “NetBeans XDebug waiting for connection message’ in the status line for long time. See the example on the image below. What is going wrong? I tried to recall what I did recently with my box and what could be the reason of such a pity that I could not use more built-in NetBeans PHP debugger.
Yes, I installed system updates including (FireFox libraries) for my Ubuntu. Little earlier I moved to NetBeans for PHP 7.0. May be something wrong is in my setup? I raise accesible manuals, digged the Net, triple times re-checked depended settings. All of them were in the right state, but Ubuntu-Apache-PHP-NetBeans bundle still not allowed me to debug PHP scripts in the habitual, effective and convenient way. For any case I restarted Apache 1st, then reboot the whole system. Nothing helped.

Eureka!

Suddenly I remembered that I used NetBeans built-in debugger not too far ago – yesterday :). It worked well for other project. I opened that project in NetBeans and started debugging session. IT WORKED! My Old Empty Head! I wasted about 2 hours searching answers in the not right place. Finally I compared project settings and discovered that Netbeans built-in debugger does not like when you trying to start debugging session from any other place that the site root ‘/’. That’s simple. It always starts (setup connection) well if you put http://yoursite.com/ into the ‘Project URL’ field. If you trying to put any subdirectory name there, e.g http://yoursite.com/project3/ your debugging session will never start.
How to resolve that?
I found 2 ways.

  • 1st, – always setup NetBeans project for the site root. Start debugging session for any script from the site root. Then setup breakpoint for script from needed subdirectory and call it. Debugger will work.
    This way is not very convenient as you can have a lot of PHP staff for the whole site installation, including some huge open source packages which does not require debugging. NetBeans spends additional time to check if there are any changes there when you open a project.
  • 2nd, – create PHP project and setup NetBeans project site root to subfolder. (In order to not register for Apache new test site for any new task I put every new task into subfolder under my local test domain, e.g. http://test.my/project3/ ).
    NetBeans will not start debugging session automatically in this case. You will see a ‘waiting for connection’ message from the image below. Do not worry. Left it as it is. Go to your browser. I use FireFox 4. And call the script you wish to debug with additional parameter, e.g.
    http://test.my/project3/index.php?XDEBUG_SESSION_START=netbeans-xdebug
    When you return to NetBeans you will see that connection with xdebug is established successfully.
    To stop XDebug session manually call any script from the same subdirectory with this parameter
    ?XDEBUG_SESSION_STOP_NO_EXEC=netbeans-xdebug

That’s all. Happy debugging with NetBeans IDE for PHP! Even from subdirectory :).
For more information about NetBeans for PHP IDE look at the articles in this category.

Related pictures:

NetBeans-XDebug Waiting for Connection

NetBeans-XDebug Waiting for Connection

XDebug is not installed

XDebug is not installed

NetBeans 7 Project Properties Run Config

NetBeans 7 Project Properties Run Config

Tags: , ,