PHP 调试 - 在哪里设置断点? 如何认证?
因此,我最近刚刚从使用 dump
、print_r
和 echo
进行临时调试转向一些更复杂的方法,我正在使用斗争。
我使用 Zend Framework、Aptana 和 Zend Debugger。
目前,我正在尝试调试自定义控制器,无论我尝试什么,我都不会到达我理解的断点,因为在使用菜单之间存在身份验证。
问题:
- 如何让我的应用程序在身份验证、登录浏览器、导航到某个 uri 然后继续调试时中断?
- 使用 MVC 在 Zend Framework 中设置断点的好地方是什么?
So I've just recently made the step from ad hoc debugging with dump
, print_r
and echo
to some more sophisticated methods and I'm having a struggle.
I work with Zend Framework, Aptana and Zend Debugger.
At this moment I'm trying to debug a custom controller and whatever I try I don't get to my breakpoint which I understand since there is authentication in between and using the menu.
Questions:
- How can I make my application break at the point of authentication, login in the browser, navigate to a certain uri and then continue debugging?
- What are good places to set breakpoints in Zend Framework with MVC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您想在请求中途更改当前用户的身份验证详细信息吗?
我认为这是不可能的。 Zend Debugger 几乎是一个只读工具。 即使是这样,您也假设您使用的任何框架都可以处理这个问题。 这意味着它必须不断尝试将其内部状态与不断变化的输入数据同步。
我认为您不应该问我们如何解决这个特定问题,而应该告诉我们为什么需要更改身份验证。 听起来您正在调试器中启动脚本,但由于没有用户会话而失败。
Zend 调试器有一个浏览器工具栏 (http://files.zend .com/help/Zend-Studio-Eclipse-Help/zend_debugger_toolbar.htm),允许您启动当前页面的调试器; 调试器将拥有浏览器发送的所有信息:cookie、发布数据等。甚至还有一个“调试下一页”设置可以帮助您调试 POST 表单。 听起来这就是你想要的。
You want to change the current user's authentication details mid-way through a request?
I don't think this is possible. Zend Debugger is pretty much a read-only tool. Even if it were, you're assuming that whatever framework you're using can handle this. That would mean it would have to constantly try to synchronize it's internal state with changing input data.
I think instead of asking us how to solve this specific problem, you should be telling us why you need to change authentication. It sounds like you're launching a script in your debugger, which fails because you have no user session.
Zend Debugger has a browser toolbar (http://files.zend.com/help/Zend-Studio-Eclipse-Help/zend_debugger_toolbar.htm) that allows you to start a the debugger for your current page; the debugger will have all information that the browser would have sent: cookies, post data, etc. There's even a "debug next page" setting which helps you debug POST forms. It sounds like this is what you want.
设置一个常量不是更容易吗?例如:
然后检查身份验证过程:
没有人能够注入该常量,而可能发生的最糟糕的事情是您最终因我的错误而离开调试模式......
您可以在定义之前进行检查:
Wouldn't it be easier to set up a constant such as:
Then check in the authentication process:
Noone will be able to inject into that constant and the worst thing that can happen is you end up leaving debug mode on my mistake...
Which you could put a check before the definition:
也许您只需要重新考虑转储解决方案(我喜欢使用断点的想法,但在像您经历的那样出现问题后又返回,我使用 Zend Studio)。 为了调试我的应用程序,我使用 Zend_Log 和 Zend_Log 的 Firebug 编写器。 firebug 将日志输出到 firebug (注意,您必须具有 <还安装了适用于 Firefox 的 href="http://www.firephp.org/" rel="nofollow noreferrer">firephp 扩展)。 将记录器存储在注册表中,您可以完成大量调试,而不会因丑陋的转储而弄乱您的视图。
Maybe you just need to rethink the dump solution (I like the idea of using breakpoints but turned back after hiccups like your experienced and I use Zend Studio). To debug my applications I make use of Zend_Log and the firebug writer for Zend_Log. The firebug outputs the log to firebug (NB you must have the firephp extension for firefox installed as well). Store the logger in your registry and you can accomplish a lot of debugging without messing up your views with ugly dumps.
好吧,我又玩了一些 zend 调试器。 (你的问题激起了老恶魔)我终于找到了“正确”的调试方法。 为了回答您登录后调试的最初问题,我会说安装适用于 Firefox 或 IE 的 zend 工具栏。 在“调试”菜单项的右侧有一个包含一些选项的下拉菜单。 其中一个选项是“下一页”。 因此,您可以转到登录屏幕,选择“下一页”,然后输入您的凭据并提交,下一页就是调试的内容。
Ok so I played with zend debugger some more. (your question stirred up old demons) and I finally figured out the "proper" way to debug. To answer your initial question to debug after login I would say install the zend toolbar for firefox or IE. To the right of the Debug menu item there is a drop down with some options. One of the options is "next page". So you can go to your login screen select "Next Page" and then put in your credentials and submit and the NEXT page is what is debugged.