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
- Go to the Run and debug panel on the left navigation menu, then click create a launch.json file.
- Add a Listen for Xdebug following (or ensure you already have it) under
configurations
: (you will need to change the port if yourxdebug
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.
- Click the green play button next to the configuration name. You will notice the layout of VS Code changing for debugging.
- Open a terminal and start the
php-fpm
process.
- Add a breakpoint.
- Access the endpoint of the application to generate a request, and you will notice the breakpoint being hit.
Congratulations! You have now got a completely working environment for Remote Development in the cloud.
Updated about 1 year ago