The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Save or edit .vscode/launch.json in your workspace directory.

Read more about Debugging with VSCode in the official documentation; including all the info about launch.json.

General Launch.json for PHP edit

This sample provides 4 launch options:

  1. Listening for Xdebug connections
  2. Launching the currently open script
  3. Launching a built-in web server
  4. Debugging PHPUnit tests with a specific filter for the ::testCaseFile method
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 0,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        },
        {
            "name": "Launch Built-in web server",
            "type": "php",
            "request": "launch",
            "runtimeArgs": [
                "-dxdebug.mode=debug",
                "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:0"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9003,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        },
        {
            "name": "Debug PHPUnit",
            "type": "php",
            "request": "launch",
            "program": "${workspaceFolder}/vendor/bin/phpunit",
            "args": [
                "--filter",
                "/::testCaseFile/"
            ],
            "cwd": "${workspaceFolder}",
            "port": 9003
        }
    ]
}

Specialty Cases edit

See Debug Semantic MediaWiki in Docker using VSCode and XDebug