Php 只能在运行测试时进行调试
使用laravel/homestead vagrant box、VS代码和PHP调试扩展,我只能在通过phpunit运行测试时设置断点和单步执行代码 如果我通过浏览器访问同一资源,我的断点永远不会被击中 基于我可以在测试运行时进行调试的事实,我假设xdebug工作正常,配置正确 My.env文件:Php 只能在运行测试时进行调试,php,laravel,xdebug,vscode-debugger,Php,Laravel,Xdebug,Vscode Debugger,使用laravel/homestead vagrant box、VS代码和PHP调试扩展,我只能在通过phpunit运行测试时设置断点和单步执行代码 如果我通过浏览器访问同一资源,我的断点永远不会被击中 基于我可以在测试运行时进行调试的事实,我假设xdebug工作正常,配置正确 My.env文件: APP_NAME=lms APP_ENV=local APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx APP_DEBUG=true APP_URL=http
APP_NAME=lms
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
APP_URL=https://lms.test
My.env.testing文件:
APP_NAME=lms
APP_ENV=testing
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
APP_URL=https://lms.test
PHP调试配置:
"configurations": [
{
"name": "Listen for XDebug on Homestead",
"type": "php",
"request": "launch",
"pathMappings": {
"/home/vagrant/code/MyProject": "C:\\Users\\lemon\\source\\vagrant\\MyProject"
},
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
app.php
'env' => env('APP_ENV', 'production'),
'debug' => env('APP_DEBUG', false),
/etc/php/7.4/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart=1
xdebug.remote_host=10.0.2.2
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512
我已经启用了xdebug日志记录。在测试期间运行调试器时,将创建日志并显示预期的条目。如果我随后删除日志文件并从浏览器中获取与测试相同的控制器,则不会创建xdebug日志
也许一些新的眼睛可以发现问题。谢谢 在绝望中,我从20-xdebug.ini中删除了这些行(并重新启动了php服务),然后它就工作了
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512
不知道为什么,但我希望这对其他人有所帮助。在绝望中,我从20-xdebug.ini中删除了这些行(并重新启动了php服务),它成功了
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512
不知道为什么,但我希望这对其他人有所帮助。在命令行上,xdebug.remote\u connect\u back=1设置无效。在web环境中,它指示Xdebug从HTTP头建立到IP地址的IDE连接。但是,如果有一个NAT网络挡住了去路,就像Docker经常遇到的情况一样,那么Xdebug无法连接HTTP头中的IP地址,因此无法进行调试连接 当您删除
xdebug.remote\u connect\u back=1
设置时,xdebug专门使用xdebug.remote\u host
设置,您自己已经正确设置了该设置(设置为10.0.2.2
)
使用Docker时,您几乎不能在命令行上使用
xdebug.remote\u connect\u back
,xdebug.remote\u connect\u back=1设置无效。在web环境中,它指示Xdebug从HTTP头建立到IP地址的IDE连接。但是,如果有一个NAT网络挡住了去路,就像Docker经常遇到的情况一样,那么Xdebug无法连接HTTP头中的IP地址,因此无法进行调试连接
当您删除xdebug.remote\u connect\u back=1
设置时,xdebug专门使用xdebug.remote\u host
设置,您自己已经正确设置了该设置(设置为10.0.2.2
)
使用Docker时,您几乎不能使用xdebug.remote\u connect\u back谢谢您的解释,这很有意义。因为这解释了为什么我会无意中投入工作,并且会帮助未来的答案寻求者,所以我接受这个答案。谢谢你的解释,这很有意义。既然这就解释了为什么我偶然发现的东西会起作用,并且会帮助未来的寻求答案者,我接受这一点作为答案。