Configuring for remote PHP debugging

CodeLobster IDE supports PHP debugging with Xdebug on a remote server. This way, you can debug absolutely any server that supports Xdebug. Before a remote PHP debugging session you should configure the IDE using the following steps:

Step 1 Configuration remote web server

  1. Firstly, you have to install Xdebug on the remote server.

  2. Open php.ini on a remote server and specify the following part of the code:

    [XDebug]
    zend_extension = <path to php_xdebug extension>;
    xdebug.remote_host = <remote server IP>;
    xdebug.profiler_enable = 0;
    xdebug.remote_connect_back = 1;
    xdebug.remote_port = 9000;
    xdebug.max_nesting_level = 256;
    xdebug.remote_handler = "dbgp";
    xdebug.remote_enable = 1;
    xdebug.remote_autostart = 1;

    • zend_extension - define a path when the Xdebug library installed.

    • xdebug.remote_host - specify the host where the debug client is running, you can either use a host name, IP address, or 'unix:///path/to/sock' for a Unix domain socket.

      [Caution]Caution

      The proper way is to specify 127.0.0.1 instead of localhost.

    • xdebug.profiler_enable - enables Xdebug's profiler which creates files in the profile output directory.

    • xdebug.remote_connect_back - If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. It checks the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables to find out which IP address to use.

    • xdebug.remote_port - specify the port to which Xdebug tries to connect on the remote host. Port 9000 is the default for both the client and the bundled debugclient. As many clients use this port number, it is best to leave this setting unchanged.

    • xdebug.max_nesting_level - controls the protection mechanism for infinite recursion protection. The value of this setting is the maximum level of nested functions that are allowed before the script will be aborted. This option is used when working with large CMS and frameworks like Yii2, Drupal.

    • xdebug.remote_handler - can only be 'dbgp' to represent the debugger protocol. The DBGp protocol is the only supported protocol.

    • xdebug.remote_enable - this switch controls whether Xdebug should try to contact a debug client. You have to enable it to run debugging session.

    • xdebug.remote_autostart - when this setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client.

  3. Restart the web server to apply your changes.

  4. Make sure that the firewall is disabled or the 9000 port is open.

Step 2 Configuration CodeLobster IDE on local computer

After configuring the remote web server, you must specify the debugger parameters on the local computer.

  1. Select Tools | Preferences | PHP Debugger main menu item to open debugger settings.

  2. Define the Virtual Folder - the path to the HTTP server virtual folder, for example, in Apache it named as DocumentRoot - the directory out of which you will serve your documents. By default, all requests are taken from this directory, but symbolic links and aliases may be used to point to other locations.

  3. Specify the IP address as the Start URL for debugging (without the project folder and index file).

  4. Check the Port that the tool uses to communicate with the CodeLobster IDE. By default, Xdebug listens on port 9000.

    [Caution]Caution

    The specified port must match the port on the remote server.

  5. When you defined xdebug.remote_autostart in php.ini you can turn on xDebug autostart feature. Xdebug will always attempt to start a remote debugging session and try to connect to a client.

  6. Click the OK button to apply changes and close preferences window.

Step 3 Configuration your project

Modify your project settings for remote debugging:

  1. Copy your project to the remote server. For example, the index.php file locates in C:/projects/myproject and you put its copy to C:/web/myproject on the remote server.

    [Caution]Caution

    Check that the same PHP code is uploaded to the remote server

  2. Select Project | Modify item from the main menu to open project properties.

  3. Specify the Project URL for debugging by entering the IP address, including the path to the project directory.

  4. Define the Project HOME URL for remote debugging (with the project start page, for example index.php).

    [Caution]Caution

    Use the actual address like http://yourdomain.com/....

  5. Click the OK button to save and close the project properties window.

Step 4 Port configuration

If you are located behind the NAT, your ports are not available, and you need to redirect the remote port to the local one using ssh. For Windows you can use Cygwin with the ssh package or Putty.

[Caution]Caution

In this case, you should use the CodeLobster IDE with settings for the local Xdebug

Port redirecting with Cygwin

  1. For windows you need to download and install Cygwin with ssh package.

  2. Run the command:

    ssh -R 9000:localhost:9000 user@server

  3. To check the port use the command:

    telnet localhost 9000

Port redirecting with Putty

  1. Download and install Putty.

  2. Create the connection to the remote server.

  3. Open Connection | SSH | Tunnels and Add new forwarded port.

  4. Click Open button.