PHP(不仅是)错误处理和错误处理的想法IDE 跳转到错误行
我对 PHP 中的错误处理有一些想法 - 立即到达代码中发生错误的位置的方法。
我已经编写了错误处理程序来捕获 PHP 错误,它加载导致错误的文件并显示该文件中的+/-几行代码。它还标记发生错误的行并打印堆栈跟踪,如下所示:
http://img834。 imageshack.us/img834/3754/err.png
现在,我有一个想法,提供一些链接(a href=),例如http协议(torrent://或sth),例如“netbeans://C:/some/file.php@110”,这将使我返回 NetBeans 编辑器,打开发生错误的文件并将光标放在行中,这会导致错误。
有什么想法可以实现这个目标吗?
I have some idea with error handling in PHP - way to immediately get to place in code where error occurred.
I have written error handler to catch PHP errors, which loads file, that caused an error and displays +/- few lines of code from that file. It also mark line where error occurred and print stack trace, like this:
http://img834.imageshack.us/img834/3754/errh.png
Now, I have an idea, to provide some link (a href=) like other than http protocols (torrent:// or sth), like "netbeans://C:/some/file.php@110" which will put me back into NetBeans editor, open file where error occurred and put cursor in line, which caused a error.
Any ideas how to achieve that goal ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要做的是注册一个自定义 url 协议。这些技术取决于底层操作系统。 这里 是 Windows 的示例。通过使用系统调用和
--open [filename]
参数打开 NetBeans,您可以打开相关文件。但是,这样您将无法转到特定的线路。为此,您需要使用 NetBeans API。如果需要,您可以使用 JNBridge 从 .NET 语言访问 Java 功能(Windows 需要此功能)。
总而言之,这并不容易,也不是跨平台的。一种更简单的方法是在服务器端使用 xDebug 并在 NetBeans 编辑器中实现该库,这将允许比您当前尝试完成的功能多得多(堆栈跟踪、代码跳转、单步执行、变量视图...... - 仅举几例)。似乎有一个针对 NetBeans 编辑器的启动提案。
如果您不想切换编辑器,可以查看 Eclipse PHP 开发工具 (Eclipse PDT) ,其中已经实现了调试器。请查看这篇文章了解设置说明。
What you need to do is register a custom url protocol. The techniques depend on the underlying operating system. here's is an example for windows. By opening NetBeans with a system call and the
--open [filename]
argument, you can open the file in question. However, that way you won't be able to go to a specific line.In order to do so, you need to use the NetBeans API. If needed, you can use JNBridge to access Java functionality from .NET languages (which you'd need for windows).
All in all, it won't be easy and not cross-platform. A much easier way to go is to use xDebug on the server side and implement the library in the NetBeans editor, which will allow a lot more functionality than what you currently try to accomplish (stack traces, Jumping in Code, Stepping, variable views, ... - just to name a few). There seems to be a started proposal on this for the NetBeans editor.
If you do not care to switch the editor, you can check out Eclipse PHP Development Tools (Eclipse PDT), which has the debugger already implemented. Check out this article on the setup instructions.
我将 xDebug 与 Netbean 的 xdebug 集成一起使用,它已经跳转到错误。
I'd use xDebug with Netbean's xdebug integration which already jumps to the errors.
NetBeans IDE 已具有此选项
请在 NetBeans IDE 中打开您的项目。
主菜单->选项->编辑器->提示->选择语言 php &选择所有复选框。
然后刷新项目显示突出显示错误或未定义变量警告。
如果使用 NetBeans IDE 进行更多操作
http://netbeans.org/kb/docs/php/editorguide.html
NetBeans IDE already has this option
Please open your project in NetBeans IDE.
main menu -> options -> editor -> hints -> select language php & select all check-boxes.
then refresh project show highlighting errors or undefined variables warnings.
if more with NetBeans IDE
http://netbeans.org/kb/docs/php/editorguide.html