Jul 24, 2017

PHP XDebug tips and tricks

A quick step-by-step walkthrough on how to get XDebug working properly and interfacing with your IDE of choice.

  1. Install XDebug on the PHP server (or docker instance). This will enable XDebug on your PHP code.
    apt-get install --no-install=recommends php5-xdebug

  2. Configure /etc/php5/mods-available/xdebug.ini on the server to enable XDebug (check the documentation for more details about the settings).
    
    zend_extension=xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_autostart=1
    xdebug.remote_connect_back=1
    xdebug.remote_host=10.0.0.1
    xdebug.max_nesting_level=500
    

  3. Ensure that the port 9000 (you can change this in the above config file) is open on the server (configure your firewall). If PHP is running as a docker service, you may need to expose/map the port and then configure your firewall to allow connections.
  4. Download or install a client program to pass the XDebug IDEKEY to the server while browsing
  5. Configure your IDE to listen on port 9000 of the server for XDebug messages

Note: You should use the browser on the same machine you have your IDE set-up, as PHP XDebug will send messages to that and only that client (depending on the configuration options).

No comments:

Post a Comment

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!