Laravel Sail-与Xdebug的Debug API

发布于 2025-01-31 23:02:31 字数 523 浏览 4 评论 0原文

我将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

━╋う一瞬間旳綻放 2025-02-07 23:02:31

您可以做两件事之一:

  1. 设置xdebug_session = someValue cookie用API调用。
  2. 更改(或添加)xdebug.start_with_request将设置设置为是YAS(而不是默认,它是trigger)。使用XDEBUG_INFO()找出要更改的INI文件。

You can do one of two things:

  1. Set the XDEBUG_SESSION=somevalue cookie with your API call.
  2. Change (or add) the xdebug.start_with_request setting to yes (instead of the default, which is trigger). Use xdebug_info() to find out which ini file to change.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文