当我停止调试时,我的 PHP 守护程序脚本继续在后台运行。当我停止调试时,如何使 xdebug 自动终止/终止我的 PHP 脚本?
我的环境:
- 带有 xdebug 扩展的 PHP 8 (cli)。
- 带有PHP 调试扩展的 Visual Studio Code 。
Visual Studio 代码(settings.json):
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "PHP Debug",
"type": "php",
"request": "launch",
"program": "${workspaceFolder}/xdebug.php",
"cwd": "${workspaceFolder}",
"runtimeArgs": [
"-dxdebug.log=/tmp/xdebug.log",
],
"env": {
"XDEBUG_MODE": "debug",
"XDEBUG_TRIGGER": "true",
"XDEBUG_CONFIG": "client_port=${port}",
},
"internalConsoleOptions": "openOnSessionStart",
},
],
},
调试测试脚本(/path/to/xdebug.php):
<?php
sleep(15);
Xdebug 日志(/tmp/xdebug.log):
[101075] Log opened at 2021-09-03 18:34:25.062284
[101075] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[101075] [Step Debug] INFO: Connected to debugging client: localhost:9003 (through xdebug.client_host/xdebug.client_port). :-)
[101075] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///path/to/xdebug.php" language="PHP" xdebug:language_version="8.0.5" protocol_version="1.0" appid="101075" idekey="true"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>
[101075] [Step Debug] <- feature_set -i 1 -n resolved_breakpoints -v 1
[101075] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="resolved_breakpoints" success="1"></response>
[101075] [Step Debug] <- feature_set -i 2 -n notify_ok -v 1
[101075] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="notify_ok" success="1"></response>
[101075] [Step Debug] <- feature_set -i 3 -n extended_properties -v 1
[101075] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="extended_properties" success="1"></response>
[101075] [Step Debug] <- run -i 4
******** I stopped debugging at 18:34:30 ********
[101075] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="4" status="stopping" reason="ok"></response>
[101075] Log closed at 2021-09-03 18:34:40.243542