Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GregorSams's avatar

Debug Laravel Command in VSCode

I am running Laravel Framework 9.48.0.

My launch.json looks like the following:

{
    // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
    // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
    // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
    "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"
            }
        }
    ]
}

When running Listen for Xdebug and I start the command via php artisan run:command I do not break at the breakpoint.

Any suggestion how to explicitly start the command in my launch.json.

I appreciate your replies!

1 like
1 reply
vural2123's avatar

It looks like your launch configuration is set up correctly, but the problem may be that the php artisan command is not running with Xdebug enabled. To ensure that Xdebug is enabled when running the command, you can try adding the -dxdebug.remote_enable=1 flag to the runtimeArgs array in the "Launch currently open script" configuration. This flag will enable Xdebug for the current script.

You can also try adding -dxdebug.mode=debug in runtimeArgs for the same config, this will enable the debug mode for the script you are running.

Additionally, you may want to check the value of the XDEBUG_CONFIG environment variable in your launch configuration to make sure it is set to the correct client port.

Finally, you can try to put some dd() or die() in your command function to see if it reach that point or not.

Please or to participate in this conversation.