Xdebug 2.3: Improvements to Debugging
This is the fourth article in a series about new features in Xdebug 2.3, which was first released on February 22nd.
In this article we are looking at the improvements towards "remote" debugging.
The first improvement is the addition to view the values of user defined constants. In Xdebug this works by defining another context. Existing contexts are local variables, and super globals. In PhpStorm, they show up in the same "Variables" box:
Xdebug 2.3 defines a third context, "User defined constants". This new third context also shows up in PhpStorm's "Variables" box:
However, if you have lots of constants, that becomes annoying. Follow (or comment on) issue WI-21691 if you want to see this changed.
Other IDEs, such as Komodo, handle this by having a separate tab for constants:
It is actually clever enough to create a new tab for every new context that I come up with, as they haven't hard coded it.
Another new debugging feature is to be able to set an exception breakpoint on all exceptions, by using * as the exception name. Xdebug 2.3 also breaks on exception classes that are inherited from the ones you set a breakpoint on. With the following code:
<?php
class BaseException extends Exception {}
class ChildException extends BaseException {}
echo "start\n";
try
{
echo "first try\n";
throw new ChildException("No noes!");
}
catch ( ChildException $e )
{
echo "eat it\n";
}
echo "end\n";
?>
And the following exception breakpoints configured in PhpStorm:
Xdebug will now interrupt the script when it hits line 11 because an exception breakpoint for both BaseException (the parent of the exception that we are throwing) and * are configured.
The third feature that I would like to highlight is related to the additions to debugging exceptions. Xdebug now includes the exception's error code in the reply to the IDE. However, it does not seem that PhpStorm allows me to see which exception it broke on, and what its message and error code are.
For now, you will have to do with the raw XML result (after formatting):
-> run -i 6
<?xml version="1.0" encoding="iso-8859-1"?>
<response
xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
command="run" transaction_id="6"
status="break" reason="ok"
>
<xdebug:message
filename="file:///tmp/xdebug-dbgp-test.php" lineno="28"
exception="FooBarException" code="43"
>
<![CDATA[this should still break]]>
</xdebug:message>
</response>
I have created issue WI-26880 in their issue tracker as a feature request.
And the last thing that has changed with debugging in Xdebug 2.3 is that now Xdebug will try to log when you do not have sufficient permissions to create a socket. For example when you have SELinux turned on but not properly configured. The new message is:
E: No permission connecting to client. This could be SELinux related. :-(
Other parts in this series:
Life Line
π· National Cycle Network 6
π© Watford, United Kingdom
π· 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



Shortlink
This article has a short URL available: https://drck.me/debugs23-bod