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: , ,

  • Anonymous

    This is how I set up mine using combination of: ubuntu, netbeans, xdebug and google chrome.

    http://arturito.net/2011/05/21/local-and-remote-php-debuging-in-netbeans-with-xdebug-on-google-chrome-just-like-in-visual-studio/

  • http://shinephp.com Vladimir Garagulya

    Thanks for sharing.

  • http://www.k9stud.com Puppies For Sale

    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.

  • http://shinephp.com Vladimir Garagulya

    I have not any troubles with NetBeans built-in debugger starting session that way.
    Can you tell us what is going wrong in your case?

  • Roberto

    I’ve the same problem and using the second way I solved; but checking in the options the browser I see that the process (I’m using Fedora 14) was wrong. In fact using Firefox 4 the correct process must be firefox4 and not firefox. So after the substitution with te correct name xdebug start automatically.  Could this solve your problem too.

  • http://shinephp.com Vladimir Garagulya

    Thanks. That’s not my case. At my Ubuntu 10.04 box browser parameter in Netbeans is
    “/usr/bin/firefox”
    where “firefox” is a shortcut to call Firefox 4
    “usr/lib/firefox-4.0.1/firefox.sh”

  • Doronbt

    I can’t believe it! you SOLVED my problem!
    After all those hours, finally a solution!
    Just changed my project to the right path and that’s it!

    Thank you!

  • Siva Budati

    After spending 18 hours trying everything from firewall settings to various versions of xdebug, this simple trick solved my problem. A big THANK YOU!!!

  • http://shinephp.com Vladimir Garagulya

    You are welcome!

  • RAFAZJ

    I haved the same trouble, with the message waiting for connection, and after read you, I fixed, the problem was the thing with the name of the site, now I do: 
    http://test.my/project3/index.php?XDEBUG_SESSION_START=netbeans-xdebug and it works!!! so, THANK YOU VERY MUCH!!!

  • http://shinephp.com Vladimir Garagulya

    You are welcome! :)

  • Tomasteicher

    for me, it doesn’t work. When I run Debug Project from Netbeans, browser is opened and I am correctly redirected to my project website. 
    XDEBUG_SESSION_START=netbeans-xdebug parameter is already added to URL. But “Waitinfg for connection” still didn’t stop. I see no debug info in netbeans. I think connection was set correctly beacause when I reload page with parameter 
    XDEBUG_SESSION_STOP_NO_EXEC=netbeans-xdebug, it shows message that debugging was stopped. But in netbenas I still have message “Waiting for connection”. 
    Can anybody help?thanksTomas

  • Captain Yahoomail

    Wow!! Bravo Dude!!!!

    After 2 days of sparing my time, this thing makes my xdebug to work. Thanks a lot and really very nice post. Please keep on posting this kind of tricks dude.

  • http://shinephp.com Vladimir Garagulya

    Thanks! It’s a pleasure to get such good review :).

  • Michael Stelly

    Holy crap! I’ve wasted so many hours with this. It’s got to be a bug. I can’t thank you enough.

  • Paolo

    I have found solution that works for me. in xdebug.conf add the following: xdebug.remote_connect_back=1
    and comment out (or delete the entire line) xdebug.remote_host=localhost (or whatever address)
    so it becomes:
    ;xdebug.remote_host=localhost
    restart apache2
    This worked for me.

  • Damien

    Man, you’re a star – this issue has been bugging me for a while, and I just fixed it following your indications ! You just made my day, thanks !!!! :-)

  • http://shinephp.com Vladimir Garagulya

    Thanks for so good words :).

  • Tufla

    Thank you so much, this solution is perfect!

  • alexei

    What worked for me was:
    Uninstall all versions of php, mysql,xamp
    I installed wamp, edited httpd.conf to change port to 8080 (since 80 is taken)
    I runned phinfo() to see if xdebug module installed, i copied all data to http://xdebug.org/wizard.php
    and saw
    Xdebug installed: 2.2.1
    Server API: Apache 2.0 Handler
    Windows: yes – Compiler: MS VC9 – Architecture: x64
    Zend Server: no
    PHP Version: 5.4.3
    Zend API nr: 220100525
    PHP API nr: 20100525
    Debug Build: no
    Thread Safe Build: yes
    Configuration File Path: C:Windows
    Configuration File: C:wampbinapacheapache2.4.2binphp.ini
    Extensions directory: c:wampbinphpphp5.4.3ext
    You’re already running the latest Xdebug version

    But here are the instructions anyway:
    Download php_xdebug-2.2.1-5.4-vc9-x86_64.dll
    Move the downloaded file to c:wampbinphpphp5.4.3ext
    Update C:wampbinapacheapache2.4.2binphp.ini and change the line
    zend_extension = c:wampbinphpphp5.4.3extphp_xdebug-2.2.1-5.4-vc9-x86_64.dll
    Restart the webserver

    I downloaded dll to php ext folder, i edited php.ini (both of them, one in php dir and second in apache dir)
    I checked that i have this:
    zend_extension = c:wampbinphpphp5.4.3extphp_xdebug-2.2.1-5.4-vc9-x86_64.dll

    [xdebug]
    xdebug.remote_enable = on
    xdebug.profiler_enable = on
    xdebug.profiler_enable_trigger = on
    xdebug.profiler_output_name = cachegrind.out.%t.%p
    xdebug.profiler_output_dir = “c:/wamp/tmp”

    restarted webserver and it finally started to work!
    I want to find the way to use port 80 instead 8080!

    Good luck to all

  • Rajeshkannan.P

    Thank you

  • http://shinephp.com/ Vladimir Garagulya

    You are welcome!