andrewtc
andrewtc

Reputation: 741

NetBeans + xdebug: No stack trace for PHP exceptions

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:

NetBeans PHP Options for xdebug

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? :)

Upvotes: 2

Views: 1523

Answers (1)

codewaggle
codewaggle

Reputation: 4943

Is display_errors turned on?

For your specific example:

<?php
    // File is not found. xdebug should stop and show the call stack.
    require 'nonexistant.php';
?>

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

Upvotes: 1

Related Questions