-
Notifications
You must be signed in to change notification settings - Fork 6
XDebug Guide
Greg Clapp edited this page Jun 15, 2020
·
16 revisions
XDebug allows you to debug PHP inside your IDE. Most developers working on PortlandOR is using Visual Studio Code as the IDE. Setup is required in both the Lando environment and the IDE. Running XDebug will slow down your app server. As a result, it's recommended that you only enabled XDebug for debugging sessions.
- Create a file
xdebug.ini
under your app root folder (portlandor
). Copy the following lines and save the file:
xdebug.remote_host = ${LANDO_HOST_IP}
xdebug.idekey = vscode-xdebug
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
- In
.lando.yml
, add two lines to include thexdebug.ini
file created in Step 1. Here is the end result.
services:
appserver:
xdebug: true
config:
conf: xdebug.ini
- Only rebuild the app server in your Lando environment:
lando rebuild -s appserver -y
- Install the extension "PHP Debug".
- Follow menu "Run -> Add Configuration" to open the launch.json file. In the
Listen for XDebug
section, add "pathMappings" to map/app/
(the source code folder in Lando app server) to your local APP root folder. "log" is optional. When it's set to true, you can see the debug logs for XDebug in VS Code.
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"pathMappings": {
"/app/": "${workspaceFolder}/",
}
}
- Follow menu "Debug -> Start Debugging" or press
F5
, the XDebug server will start listening for incoming connections. - Click at the start of a line in
index.php
to set a breakpoint. - Load any page on your Lando site and verify execution stops at the breakpoint.
In one occasion, the breakpoint was not hit until VS Code is updated to the latest (v1.23.1 at the time of writing). If your breakpoint is not hit, try to update VS Code.