View Issue Details

IDProjectCategoryView StatusLast Update
0001898XdebugUncategorizedpublic2021-10-04 09:32
Reportersebastian Assigned Toderick  
Status closedResolutionfixed 
Product Version3.0.0RC1 
Target Version3.1devFixed in Version3.1.0 
Summary0001898: API for querying the currently active mode(s)

I would really like for Xdebug to provide a function that returns information about which mode(s) is/are currently active. The motivation for this can be found here

TagsNo tags attached.
Operating System
PHP Version7.4.0-7.4.4


has duplicate 0001959 closedderick Add a function to obtain xdebug.mode settings 



2020-11-27 12:00

administrator   ~0005549

Sebastian's reasoning:

Besides setting the mode with xdebug.mode, you can also set the mode with the XDEBUG_MODE environment variable. If this environment variable is active, it overrides the mode as set through xdebug.mode.

I understand that Xdebug looks at the XDEBUG_MODE environment variable and changes its mode based on that. As far as I can see, though, Xdebug does not provide an API for querying its mode apart from using ini_get('xdebug.mode') (or using xdebug_info(), capturing its output through output buffering, and then parsing the generated HTML).

For a short term solution, this library can fall back to looking for/at the XDEBUG_MODE environment variable. If it is set, its string contents will be treated like the string contents of ini_get('xdebug.mode') is right now:

if (!ini_get('xdebug.mode') || !in_array('coverage', explode(',', ini_get('xdebug.mode')), true)) {
throw new Xdebug3NotEnabledException;

The message of Xdebug3NotEnabledException, of course, needs to be adapted.

In the long run, though, I would really like for Xdebug to provide a function that returns information about which mode(s) is/are currently active.


2021-04-21 16:41

administrator   ~0005857

I have settled on the following API:

$ XDEBUG_MODE=debug,coverage php -dxdebug.mode=trace -r 'var_dump(xdebug_info("mode"));'
array(2) {
string(8) "coverage"
string(5) "debug"

Does that work for you?

PR @


2021-04-22 05:04

reporter   ~0005858

Thank you for this birthday present ;) Yes, that works for me.


2021-04-23 10:51

administrator   ~0005859

Issue History

Date Modified Username Field Change
2020-11-27 07:18 sebastian New Issue
2020-11-27 12:00 derick Status new => confirmed
2020-11-27 12:00 derick Target Version => 3.0dev
2020-11-27 12:00 derick Note Added: 0005549
2020-12-04 12:50 derick Target Version 3.0dev => 3.1dev
2021-03-21 20:44 derick Relationship added has duplicate 0001959
2021-04-21 16:41 derick Assigned To => derick
2021-04-21 16:41 derick Status confirmed => feedback
2021-04-21 16:41 derick Note Added: 0005857
2021-04-22 05:04 sebastian Note Added: 0005858
2021-04-22 05:04 sebastian Status feedback => assigned
2021-04-23 10:51 derick Status assigned => closed
2021-04-23 10:51 derick Resolution open => fixed
2021-04-23 10:51 derick Fixed in Version => 3.1dev
2021-04-23 10:51 derick Note Added: 0005859
2021-09-05 16:15 derick Fixed in Version 3.1dev => 3.1.0beta1
2021-10-04 09:32 derick Fixed in Version 3.1.0beta1 => 3.1.0