Laravel Sail-与Xdebug的Debug API
我将Laravel Sail用于开发环境,我想使用Xdebug来调试我的PHP Laravel代码。
我已经根据文档设置Xdebug: https://laravel.com/docs.com/docs/9.x/sail# with-xdebug debugging
但是,该文档仅显示如何从浏览器或调试CLI命令中Xdebug,那API呢?如果我在我的PHP代码中设置了一个断点,并使用Postman发送API请求,则不会达到任何断点。作为快速测试,我使用Xdebug扩展程序打开了浏览器,并输入了API URL,断点可行。
这不是我想调试代码的方式,我无法正确调试我的API,因为它们需要某些参数和身体内容,并使用某些标头,而我无法在浏览器中进行操作。
因此,这就提出了一个问题,您如何在Laravel帆中使用Xdebug?
I'm using Laravel Sail for my development environment and I'm wanting to use Xdebug to debug my PHP Laravel code.
I've set up Xdebug as per the documentation here:
https://laravel.com/docs/9.x/sail#debugging-with-xdebug
However, the documentation only shows how to Xdebug from a browser or debugging CLI commands, what about APIs? If I set a breakpoint in my PHP code and use Postman to send an API request it does not hit any breakpoints. As a quick test, I opened my browser with the Xdebug extension and typed in the API url, the breakpoint works.
This is NOT the way I want to be debugging my code, I can't debug my APIs properly because they require certain parameters and body contents with certain headers which I can't do in a browser.
So this begs the question, how do you APIs using Xdebug in Laravel Sail?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做两件事之一:
xdebug_session = someValue
cookie用API调用。xdebug.start_with_request
将设置设置为是YAS
(而不是默认,它是trigger
)。使用XDEBUG_INFO()
找出要更改的INI文件。You can do one of two things:
XDEBUG_SESSION=somevalue
cookie with your API call.xdebug.start_with_request
setting toyes
(instead of the default, which istrigger
). Usexdebug_info()
to find out which ini file to change.