Debug PHP

Pre-requisites

First, make sure to install the VS Code extension for PHP Debug or an equivalent.

Once the connection is established, we can proceed to setting up debugging.


Steps

  1. Go to the Run and debug panel on the left navigation menu, then click create a launch.json file.
3456
  1. Add a Listen for Xdebug following (or ensure you already have it) under configurations: (you will need to change the port if your xdebug extension is running on a custom port).
"configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        }
    ]

You will be able to see the new configuration in the top of the screen.

3454
  1. Click the green play button next to the configuration name. You will notice the layout of VS Code changing for debugging.

  1. Open a terminal and start the php-fpm process.
3456
  1. Add a breakpoint.
3456
  1. Access the endpoint of the application to generate a request, and you will notice the breakpoint being hit.
3456

Congratulations! You have now got a completely working environment for Remote Development in the cloud.