NetBeans + xdebug:没有 PHP 异常的堆栈跟踪
我是一名 C++/C# 程序员,拥有一些使用 PHP 构建网站的经验。我最近安装了 NetBeans 和 xdebug,因为我无法再忍受没有调试器的工作。单步执行代码就像一个魅力,但似乎无法让 xdebug 在异常上暂停并向我显示调用堆栈。
下面是一个示例:
<?php
// File is not found. xdebug should stop and show the call stack.
require 'nonexistant.php';
?>
我正在使用本地 MAMP PRO 2.0.1 服务器的 Mac (Snow Leopard) 上运行。我有 NetBeans 7.0.1,配置为使用我的 MAMP PHP 解释器和 xdebug 2.1.0 运行。以下是我当前的 xdebug 设置,位于“php.ini”文件中:
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
这是我在 NetBeans 中的设置的屏幕截图:
我已经验证了“php.ini”中的设置正在加载,并且 NetBeans 已正确配置用于调试,但我仍然无法获得异常或内部错误来生成堆栈跟踪。有接受者吗? :)
I am a C++/C# programmer who has some experience building websites with PHP. I recently installed NetBeans and xdebug because I couldn't stand working without a debugger anymore. Stepping through the code works like a charm, but can't seem to get xdebug to pause on exceptions and show me the call stack.
Here's an example:
<?php
// File is not found. xdebug should stop and show the call stack.
require 'nonexistant.php';
?>
I am running on a Mac (Snow Leopard) using a local MAMP PRO 2.0.1 server. I have NetBeans 7.0.1, configured to run using my MAMP PHP interpreter, with xdebug 2.1.0. Here are my current xdebug settings, located in my "php.ini" file:
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
Here's a screenshot of my settings in NetBeans:
I have verified that the settings in "php.ini" are being loaded, and that NetBeans is configured properly for debugging, yet I still can't get an exception or internal error to produce a stack trace. Any takers? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
display_errors 是否打开?
对于您的具体示例:
您正在创建一个致命错误,并且需要在 php.ini 中打开 display_errors。
如果您在运行时使用 ini_set(),则不会显示致命错误。
要查看捕获的异常的堆栈跟踪,您需要打开:
xdebug.show_exception_trace
一切顺利,
乔
Is display_errors turned on?
For your specific example:
You're creating a fatal error and display_errors needs to be turned on in php.ini.
A fatal error won't be displayed if you're using ini_set() at runtime.
To see the stack trace for an exception that is caught, you need to turn on:
xdebug.show_exception_trace
Be Well,
Joe