-
Notifications
You must be signed in to change notification settings - Fork 6
XDebug Guide
Richard Davies edited this page Dec 16, 2020
·
16 revisions
XDebug allows you to debug PHP inside your IDE. Most developers working on PortlandOR are 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 enable XDebug for debugging sessions.
Note: This section is included here for completeness, although this should already be included in the code checked out from GitHub.
- Create a file
xdebug.ini
under your app root folder (portlandor
). Copy the following lines and save the file:
xdebug.mode = debug
xdebug.client_host = ${LANDO_HOST_IP}
xdebug.idekey = vscode-xdebug
xdebug.client_port = 9003
xdebug.start_with_request = trigger
xdebug.max_nesting_level = 256
;xdebug.log = /tmp/xdebug.log
-
.lando.yml
needs the following lines to include thexdebug.ini
file created in Step 1.
services:
appserver:
xdebug: false
config:
php: xdebug.ini
overrides:
environment:
XDEBUG_MODE:
- Rebuild the app server in your Lando environment:
lando rebuild -y -s appserver
- Install the extension "PHP Debug".
- Follow menu "Run -> Add Configuration" to open the launch.json file. Change the
Listen for XDebug
section to the following: ("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": 9003,
"log": false,
"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. Or usexdebug_break();
to trigger a breakpoint in the code. - Load any page on your Lando site and verify execution stops at the breakpoint.