-
Notifications
You must be signed in to change notification settings - Fork 6
XDebug Guide
kxwang edited this page May 15, 2018
·
16 revisions
XDebug allows you to debug PHP inside your IDE. In PortlandOR, the IDE is Visual Studio Code. 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 = 10.0.75.1
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
- (Optionally) Get your environment ready:
lando composer install
lando db-import DB_FILE_HERE
lando drush cim -y
- Install the extension "PHP Debug".
- Follow menu "Debug -> Open Configurations" 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/": "c:/work/lando/portlandor/",
}
}
- 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 see execution stops at the breakpoint.