VSCode + PHP + xdebug + launch.json

Mar*_*sen 5 php xdebug launch visual-studio-code

我有一个 Laravel 项目,并且我有 Xdebug 在 VSCode 中工作。

但不幸的是我分两步进行。我想把它合二为一。

我现在在做什么,我写道:

  1. 在命令中:

    php -S localhost:1000 -t public
    
    Run Code Online (Sandbox Code Playgroud)
  2. 有一个 VSCode > debug > launch.json

    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000
    },
    
    Run Code Online (Sandbox Code Playgroud)

我怎样才能将其合并为一项任务?

我尝试将 1. 部分创建为任务,但没有成功。

任务.json:

{
    "taskName": "PhpServe",
    "type": "shell",
    "command": "php -S localhost:1000 -t public"
}
Run Code Online (Sandbox Code Playgroud)

启动.json

{
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "preLaunchTask": "phpServe",
    "port": 9000
},
Run Code Online (Sandbox Code Playgroud)

PHP 服务器启动并运行,直到我关闭它。关闭它后,Xdebug 启动。不是我想要的。

如何同时启动 PHP 服务器和 xdebug?