Register

Author Topic: Getting Xdebug to work with the Eclipse IDE  (Read 38 times)

Randem

  • Administrator
  • Hero Member
  • *****
  • Posts: 2671
Getting Xdebug to work with the Eclipse IDE
« Reply #1 on: May 08, 2019, 07:46:14 PM »
We have been using Eclipse with Xdebug, WampServer and PHP for a while and run into some issues that did not allow the debugger to operate, so we have decided to share these issues and solutions to help others use these incredible tools. So when you can't get your debugger to work or it suddenly stops working try these few things you can try to get it back working or at the very least know why it is not working. It is also very important that if you have run your program with an .htaccess file that had redirection in it (I.E. http to https) you will need to  remove the redirection from your .htaccess file, clear the browser cache and restart the browser before you attempt to run it again or it will not work until you do.

  • Make sure your .htaccess file is not corrupted. to check this out, just rename your .htaccess file and try Eclipse again. If it still does not work, this may not be your issue. If it does work then you may have a corrupted file or you may have some commands that do not work properly in the WampServer environment that would normally work on the hosted system and you will need to weed them out by the process of elimination. Remove all commands from the .htaccess file then add the commands or sections back one at a time until it fails again, you will then have your answer.

  • Change in your Apache httpd.conf file to stop Xdebug and Eclipse from attempting to listen to IPv6 protocol. Look into the file and comment out the IPv6 listen statement. We have gotten messages concerning INET_ATON() when this is the case. Changing this fixed the situation.

    #Listen 12.34.56.78:80
    Listen 0.0.0.0:80
    #Listen [::0]:80


  • Change your Port number in your php.ini file and in Eclipse to another unused port number. Port 9000 is usually used in DVR systems and if you have one on your network there may be confusion. I like Port 9005.  In Eclipse change the port number in Run->Debug Configurations->PHP Server Configure->Debugger.  Also add the following lines to the [xdebug] section of your php.ini file.

    zend_extension = c:/wamp64/bin/php/php5.6.35/zend_ext/php_xdebug-2.5.5-5.6-vc11-x86_64.dll

    xdebug.remote_enable=1
    xdebug.remote_connect_back=1
    xdebug.remote_port=9005
    xdebug.remote_handler="dbgp"
    xdebug.remote_autostart = 1


    The autostart parameter is important if you want to operate in your external browser and have Eclipse be triggered from there when you use a url. the php_xdebug-2.5.5-5.6-vc11-x86_64.dll file and location will need to be changed to the actual file and location that you need to use to get Xdebug to install. After making these changes you will need to restart all services in WampServer for it to take effect.

  • If you are using WampServer; look in the c:\wamp64\www folder (the location where you installed WampServer) to find the phpinfo.php file. Open a browser then type in the following localhost/phpinfo.php or just open localhost from the WampServer menu when you click on the WampServer icon in the icon tray at the bottom right of your display then click on phpinfo() under the Tools heading on the localhost page. In your browser search the phpinfo page for xdebug. If you do not find it, then Xdebug is not installed and this is one reason why it does not work. If found; you should see some text like this meaning Xdebug is installed:

    This program makes use of the Zend Scripting Language Engine:
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans


    Another way is to visit the Xdebug site at https://xdebug.org/wizard.php then copy and paste the information from your phpinfo page into the wizard and it will give you some valuable information about your installation including the version of Xdebug that you should download and install. The download page is at https://xdebug.org/download.php. Note that some versions of Xdebug will not work with other versions of PHP, but at least you will have a clue. At the time of this writing most hosts are still running PHP 5.6 and Xdebug does not support it anymore but you can still get it to run in Eclipse with an older version of Xdebug (php_xdebug-2.5.5-5.6-vc11-x86_64.dll). So your first option would be to make sure that Xdebug gets installed. You may need to load several different version until you get one to install with your version of PHP. This is also the very first thing to check if Xdebug suddenly stops working or works erratically. Note that you can get a version of Xdebug to install with your PHP version but it may not work properly and you get errors like "Depreciated call create_function" in your PHP Error Log. This basically means that your Xdebug is for PHP 7.x and greater and you have installed in on PHP 5.x

  • If you have changed your Eclipse to work with an external browser; you may need to change this to use other browsers. It did not work with Firefox 66.0.4 consistently. We are currently using Eclipse Proton 2018 and it would work for a while then suddenly stop and we needed to switch to another browser like Chrome or the Internal browser to get it to work again. When the internal browser stopped working we had to start with step 4 all over again for Xdebug has stopped being loaded for some reason. It is possible that Xdebug had stopped loading and we could have just went straight to step 4 to get Firefox to work again. We will test this when it happens again. This may just be a simple conflict situation with Xdebug and another system on the computer.


If we find any more solutions that can help you with Xdebug and Eclipse we will post them here in this list.