Reputation: 384
I am runnig PHP CLI application.
If I set a breakpoint, xdebug stops on it. if I write xdebug_break();
it stops as well.
Can I make it stop if application throws an exception?
My ini file:
php -i | grep php.ini Loaded Configuration File => /etc/php5/cli/php.ini
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
Upvotes: 5
Views: 1213
Reputation: 825
I know this may be a bit late to the game, but you could use:
function my_exception_handler(Throwable $e) {
if (function_exists('xdebug_break') )
xdebug_break();
die('Exception: ' . $e->getMessage() );
} // Function //
set_exception_handler('my_exception_handler');
As it states in the xdebug documentation:
bool xdebug_break()
Emits a breakpoint to the debug client.
This function makes the debugger break on the specific line as if a normal file/line breakpoint was set on this line.
Upvotes: 2
Reputation: 181
Not possible with xdebug alone however in php you can use the set_exception_handler to register a function that catches uncaught exceptions. You can then place a breakpoint in that function.
See http://php.net/manual/en/function.set-exception-handler.php
You can do the same for errors:
http://php.net/manual/en/function.set-error-handler.php
Upvotes: 1