Skip to content

Instantly share code, notes, and snippets.

@IlanVivanco
Last active September 3, 2021 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IlanVivanco/4679c578eb3035ca1ecadc025b207999 to your computer and use it in GitHub Desktop.
Save IlanVivanco/4679c578eb3035ca1ecadc025b207999 to your computer and use it in GitHub Desktop.
Xdebug config for Devilbox

Extracted from cytopia/devilbox#718 issue

  • ~/.zshrc or ~/.bashrc
export IP=$(hostname -I)
  • _~/.devilbox/.env
PROJECTS_PATH=~/code
  • ~/.devilbox/docker-compose.override.yml
version: '2.3'

services:
  php:
    volumes:
      - ${PROJECTS_PATH}/my-plug:/shared/httpd/my-site/htdocs/wp-content/plugins/my-plug
    extra_hosts:
      docker.for.wsl2.host.internal: ${IP}

  httpd:
    volumes:
      - ${PROJECTS_PATH}/my-plug:/shared/httpd/my-site/htdocs/wp-content/plugins/my-plug
  • ~/devilbox/cfg/php-ini-7.4/xdebug.ini
; Defaults
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9000

; The WSL2 way
xdebug.discover_client_host=0
xdebug.client_host=docker.for.wsl2.host.internal

; idekey value is specific to Visual Studio Code
xdebug.idekey=VSCODE
  • ~/code/my-plug/.vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
  {
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9000,
    "pathMappings": {
    "/shared/httpd/my-site/htdocs/wp-content/plugins/my-plug": "${workspaceFolder}"
    }
  },
  {
    "name": "Launch currently open script",
    "type": "php",
    "request": "launch",
    "program": "${file}",
    "cwd": "${fileDirname}",
    "port": 9000
  }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment