I just tried setting up Eclipse with PHP support and Xdebug integration and it was rather quick. It shouldn't take more than 5-10 minutes if you have php, xdebug and eclipse installed.

Step 1. Verify that xdebug is properly installed.
Create a web-accessible php script with phpinfo(). Check the xdebug section. Default port is 9000. You will also need

xdebug.remote_enable	On	On
xdebug.remote_handler	dbgp	dbgp

Step 2. Eclipse setup
* Eclipse -> settings -> PHP->Servers (also reachable from PHP->Debug: PHP Servers...)
Change "debugger" from Zend to Xdebug
Base url: This is the url base for remote server. http://localhost/ works (if your remote server is localhost). If you have domains in /etc/hosts pointing to localhost, you could use these as well. E.g. http://my.example.com/. The remote hosts obviously does not need to be on localhost.
Local webroot: file path to docroot (or other directory matching url rewrites). e.g. /path/to/example-root/

  • If you don't already have a PHP executable, click "PHP Executables". Then add (or edit existing in the list). Add a name for it, e.g. php 5.6, specify path to php executable, e.g. /usr/local/bin/php and SAPI: CLI or sbin/php-fpm and SAPI: CGI. Then whatever php.ini is used, e.g. /usr/local/etc/php/5.6/php.ini.

  • Eclipse -> settings ->PHP->Debug
    Select the previously created server here. Make sure it says Xdebug and not Zend when you select it.
    Select the previously created php executable config. It should also say Xdebug.

  • Eclipse -> settings -> PHP -> Deug -> Installed Debuggers
    Xdebug should be listed with port 9000 (unless of course you change xdebug config).

  • Eclipse -> Run -> Run Configurations
    Double click PHP Web App
    Select previously created PHP Server
    File: /eclipse-project-folder/rel-path/to/index.php
    url: fully qualified remote host
    e.g. http://my.example.com/

    followed by path for initial request (may be empty)

I hope it helps 🙂

    Nice write up. Of course, you tend to always make nice write-ups 🙂

    $step_one .="in your configuration (php.ini, php.conf) file."

    //step two, what about Windows? C:\path\to\php.exe

    🙂

      This looks really useful! I can't try it out just yet but will certainly do so when I am able.

      Given my experience with trying this before, I seem to recall that rewrite rules can make things quite trick as PDT has a fairly primitive means of matching up one's url with the corresponding source file. In CodeIgniter, for instance, a url like this:

      http://example.com/controller/method/arg

      Would result in the file index.php being accessed. Here's the mod_rewrite directives in the .htaccess file:

      RewriteEngine on
      RewriteCond $1 !^(index\.php|images|robots\.txt)
      RewriteRule ^(.*)$ /index.php/$1 [L]
      

      Any suggestions on PDT configuration to deal with this scenario?

        OK I'm going to have a go at this again.

          Write a Reply...