调试 PHP - 选择 Xdebug 会话的请求
我使用 NetBeans 和 Xdebug 处理 PHP 代码。我使用 Xdebug 进行逐步调试等。
我可以调试默认请求的流程,但不能调试特定 _get/_post 或 Ajax 请求生成的流程。
有人知道如何做到这一点吗?
当我运行调试器时,浏览器中会自动打开一个选项卡,其中包含以下 URL: http://localhost/?XDEBUG_SESSION_START=netbeans-xdebug
谢谢。 吉迪
I work on PHP code with NetBeans and Xdebug. I use Xdebug for step-by-step debugging and the like.
I'm able to debug the flow of the default request, but not the flows generated by specific _get/_post or Ajax requests.
Anybody has an idea how can this be done?
When I run the debugger, a tab in my browser opened automatically with the following URL:
http://localhost/?XDEBUG_SESSION_START=netbeans-xdebug
Thanks.
Gidi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,
事情是这样的:
在“项目”选项卡(我的配置中屏幕的左上角)中,右键单击项目名称,然后单击“属性”=>“运行配置
你必须填写 3 个表格:
1. 项目 url - 项目在网络上的基本 url,通常是 http://localhost
2. 索引文件 - 使用浏览按钮并转到 index.php 的本地副本或任何为您提供此功能的文件。该表单应包含本地文件系统中该文件的路径,而不是网络上的路径。
3. 参数 - 您希望通过 URL 路径到脚本的任何参数
这应该使您能够选择自定义 URL 进行调试
一个可能的问题:在此过程中,您可能会失去 Web 地址与您的脚本中的相应文件之间的同步。系统。如果遇到这种性质的问题,请谷歌“php 调试器中的路径映射”,并获取第一个结果(系统不允许我直接链接)。
然而这对我不起作用。我使用服务器配置通过重定向 URL
Gidi
p.s. 来解决这个问题。
以上所有内容并没有解释如何在调试时将 POST 变量传递给脚本(我确实不知道该怎么做)
Ok,
it goes this way:
At the projects tab (top left of the screen in my configuration), right click on the name of the project, and then properties => run configuration
There you have to fill 3 forms:
1. project url - the base url of the project on web, typically http://localhost
2. index file - use the browse button and go to the local copy of index.php or whatever file serves this role for you. This form should contain the path to this file in the local filesystem , not on the web
3. arguments - any arguments you wish to path to your script through the URL
This should give you the ability to choose a custom URL for debugging
A possible problem: in this process you may loose the synchronization between web addresses and the corresponding files in your system. Google "path mapping in php debugger" if you encounter issues of this nature, and take the first result (which the system wouldn't allow me to link directly).
However this didn't work for me. I used server configuration to overcome this issue by redirecting URLs
Gidi
p.s.
All the above doesn't explain how to pass POST variables to your script while debugging (and I indeed don't know how to do it)
也许您尝试如上所述启动调试会话。作为调试目标,您可以在工作流程中选择距离 POST 请求最近的页面。然后,您与 Web 服务交互,始终让 netbeans 中的调试器运行。通过交互,调试会话将保持,因此您可以填写表单等并发送 POST 请求。然后切换到 netbeans 并像往常一样进行调试。
也许您必须在调试选项中启用“在第一行中断”,或者在分派请求的 php 代码中设置断点,以确保调试器在分派 POST 请求时停止。然后,您最终将不得不在每次页面加载时向调试器推送。
希望有帮助
Perhaps you try to start a debug session as described above. As debug target you choose the nearest page to your POST request in the workflow. Then you interact with the web service, always having the debugger in netbeans running. With the interaction the debug session holds on, so you can fill forms etc. and send the POST request. Then switch to netbeans and debug as usual.
Perhaps you have to enable 'Break at first line' in the debug options, or set up a breakpoint in the php code, where the request is dispatched, in order to ensure the debugger halts while dispatching the POST request. Then you eventually will have to give the debugger a push at every page load.
Hope it helps