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.
![srdev-02.png 3456](https://files.readme.io/e68f081-srdev-02.png)
- 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.
![srdev-03.png 3454](https://files.readme.io/75da52b-srdev-03.png)
- 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.
![srdev-04.png 3456](https://files.readme.io/b6c82a7-srdev-04.png)
- Add a breakpoint.
![srdev-01.png 3456](https://files.readme.io/c6cddb3-srdev-01.png)
- Access the endpoint of the application to generate a request, and you will notice the breakpoint being hit.
![srdev-06.png 3456](https://files.readme.io/d8fee1f-srdev-06.png)
Congratulations! You have now got a completely working environment for Remote Development in the cloud.
Updated 8 months ago