Skip to content

Instantly share code, notes, and snippets.

@vburlak
Forked from dluco-/Readme.md
Created June 13, 2020 09:06
Show Gist options
  • Save vburlak/29864e29987e5cfbdacd2de017cbb795 to your computer and use it in GitHub Desktop.
Save vburlak/29864e29987e5cfbdacd2de017cbb795 to your computer and use it in GitHub Desktop.
Setting up Xdebug to work with trellis and Visual Studio Code.

Set up Trellis

https://roots.io/trellis/docs/installing-trellis/

Set up php debugging in Visual Studio Code

Follow this guide: https://code.visualstudio.com/Docs/languages/php

PHP extension

https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
No need to install xdebug on your local machine.

.vscode/launch.json

Replace XXXXXXXXXX with example.dev or whatever from trellis/group_vars/development/wordpress_sites.yml

wordpress_sites:
  example.dev: // <-- This
  
---------------------------------------

{
    "version": "0.2.0",
    "configurations": [{
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "serverSourceRoot": "/srv/www/XXXXXXXXXX/current/web",
        "localSourceRoot": "${workspaceRoot}/site/web",
        "port": 9000
    }, {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }]
}

Enable debugger

Download xdebug extension for your browser https://xdebug.org/docs/remote. Links under Starting The Debugger header.

Start

Enable debugging in the browser extension. Press F5 in VS to start debugging. Voilá!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment