mys*_*age 3 php xdebug visual-studio-code
I ran this command:
"C:\xampp\php\.\php.exe" "C:\xampp\php\phpunit" -d xdebug.profiler_enable=on -d xdebug.idekey=VSCODE
C:\xampp\php\php.ini has the following:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.0-7.1-vc14.dll"
xdebug.idekey=VSCODE
xdebug.profiler_enable=1
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
Run Code Online (Sandbox Code Playgroud)
If I run the command without Listen for XDebug, I will see the following in the command line window:
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from C:\xampp\apps\summit\htdocs\wp-content\plugins\hl-market-tracker\phpunit.xml.dist
...
Run Code Online (Sandbox Code Playgroud)
I went into VSCode and Listen for XDebug and when I run the command, I see Request 1 and 2 appears in the Call Stack but no unit test got run (it seems to be hung somewhere because Installing...
doesn't even show up in the command line window). If I stop listening for Xdebug, I will see read ECONNRESET
in the debug console, and then I will see the Running as single site...
statement being printed out (but not the Installing...
statement)
Questions:
I would like to understand how to get debugging to work when I try to run the unit test?
Why did I see the hung behavior described above? What am I not understanding?
References:
#2的答案:https : //github.com/felixfbecker/vscode-php-debug/issues/164:所描述的根本问题是,当运行两个php进程时,它混淆了VS Code的调试器。当我读到这篇文章时,我以为是因为每当运行php时,它都会从php.ini中读取数据,并且文件告诉xdebug监听端口9000,这就是为什么如果运行了两个php进程,XDebug就会感到困惑。由此,我看到phpunit使用phpunit选项启动php。然后,我想用一个不同的远程端口启动这个特定的php,以查看它是否解决了挂起的问题,并且做到了。
#1的答案:因此,在VS Code的launch.json中,
一种。添加另一个配置以侦听另一个端口上的XDebug(8000)
"name": "PHPUnit",
"type": "php",
"request": "launch",
"port": 8000
Run Code Online (Sandbox Code Playgroud)
b。从命令行启动时使用此命令
"C:\xampp\php\.\php.exe" -d xdebug.remote_port=8000 "C:\xampp\php\phpunit"
Run Code Online (Sandbox Code Playgroud)
或者,在phpunit.bat中对其进行更改,使其能够仅在命令行中输入phpunit
笔记:
FWIW - 在 Ubuntu 上,在 launch.json 中设置以下内容适用于我(通过 apt 安装了 XDebug):
"configurations": [
{
"name": "Launch Unit Tests",
"type": "php",
"request": "launch",
"program": "${workspaceFolder}/vendor/bin/phpunit",
"cwd": "${workspaceFolder}",
"env": {
"XDEBUG_CONFIG": "idekey=VSCODE remote_enable=1 profile_enable=1"
},
"args": [
// "--filter",
// "testCanCreateValid"
],
"port": 9000
}
]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1337 次 |
最近记录: |