Contributing Advent 20: Xdebug halting on error
After Rob came up with the idea for xdebug_print_function_stack() from episode 17 he filed another issue. This new issue request thats a new setting to be added to Xdebug that allows users to decide whether notices and warnings should be treated as (fatal) errors. It's very much like GCC's -Werror setting which converts every compiler warning into an error that aborts the compilation process. The article for episode 4 talks a bit more about GCC's flags.
But as we are talking about PHP and Xdebug here, lets focus on this new feature that I added. xdebug.halt_level is a setting that allows you to configure a mask. This mask determines which notices get converted to errors. Right now, you can configure notices and warnings that are generated by PHP, and notices and warnings that you generate yourself (by means of trigger_error()). For example, to convert the warning of strlen() (without arguments) to an error, you would do:
<?php
ini_set('xdebug.halt_level', E_WARNING);
strlen();
?>
Which will then result in the showing of the error message, and the abortion of the script. echo "Hi!\n"; will not be executed.
The new setting is a bit mask, so to convert all notices and warnings into errors for all applications, you can set this in php.ini:
xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE
And that means, that errors created by trigger_error() also cause the termination of the script.
This new feature is going to be part of Xdebug 2.3. Stay tuned!
Comments
Ok this is good and it's probably a bit late to comment, but instead of halting it would be nice to make it stop (not error/exit) like a breakpoint. Or are we talking about the same thing? :)
Thanks for a great product!
Andrew
@Andrew: Xdebug already supports that through an exception breakpoint on Notice. Not many IDEs support that though.
Life Line
π· Tufted Duck Pair
π© Outer Circle, City of Westminster, United Kingdom
RE: https://phpc.social/@Xdebug/115662135830755552
I have just released Xdebug 3.5.0!
In the next few weeks I will create some content (text, and perhaps video) highlighting some new features in more detail.
Please share it with the world!
The master branch is now for Xdebug 3.6, targetting PHP 8.6
Back to -dev
Tweak release instructions a little
Go with 3.5.0
Tweak message IDs and severities for control socket log entries
I walked 8.5km in 1h30m56s
My whisky of the month for December 2025, is a 15yo Aultmore bottled by Cadenhead's.
Fixed off-by-one error in address length name for control socket on Lβ¦
Merged pull request #1050
Fixed control socket name by removing silly trailing things (by not pβ¦
RE: https://en.osm.town/@harry_wood/115650834037247679
Fancy a friendly #OpenStreetMap chat in the pub, with some Christmas celebrations?
The London OSM gang is meeting on December 16th near Paddington.
I walked 8.7km in 1h29m30s
RE: https://mastodon.online/@afup/115648919275171255
This talk on what's New in PHP 8.5 is in English! Je ne parles pas FranΓ§ais!
I walked 10.0km in 1h46m14s
Merged pull request #1049
Reorder xdfree(name) and removing trailing whitespace
Tweak comments to use /* .. */ style
Reuse created \\.\pipe name


Shortlink
This article has a short URL available: https://drck.me/adv1320-aff