View Issue Details

IDProjectCategoryView StatusLast Update
0002174XdebugProfilingpublic2023-09-04 11:26
ReporterLeon Assigned Toderick  
Status resolvedResolutionno change required 
Product Version3.2.1 
Target Version3.2dev 
Summary0002174: start_with_request not settable via XDEBUG_CONFIG

It appears that the 'start_with_request' setting cannot be set via XDEBUG_CONFIG.

XDEBUG_MODE: debug,profile
XDEBUG_CONFIG: client_host= output_dir=/opt/xdebug/profiles start_with_request=trigger

The 'client_host' and 'output_dir' settings are correctly used, but 'start_with_request' remains set to 'default'.

See screenshots, you can see 'output_dir' is correctly set via XDEBUG_CONFIG, but 'start_with_request' is not.

Steps To Reproduce
  1. Run PHP with following environment variables:
    XDEBUG_MODE: debug,profile
    XDEBUG_CONFIG: start_with_request=trigger

  2. Observe in phpinfo() that start_with_request is still set to 'default'

Additional Information

PHP 8.1.9
Xdebug 3.2.1

TagsNo tags attached.
Attached Files
2023-04-12_14:23:58.png (19,786 bytes)   
2023-04-12_14:23:58.png (19,786 bytes)   
2023-04-12_14:31:07.png (209,931 bytes)   
2023-04-12_14:31:07.png (209,931 bytes)   
Operating System
PHP Version8.1.5-8.1.9



2023-05-24 16:09

administrator   ~0006562

This is in line with the documentation. Only some settings are settable through XDEBUG_CONFIG, as described at The documentation does not state it can be set there.

What is your specific use case here?

Ideally, PHP itself would have functionality to do this, so that I don't have to hack it for Xdebug...


2023-05-24 16:19

reporter   ~0006564

The documentation does not state it can be set there.

Oh I must have missed that, apologies!

What is your specific use case here?

The use-case here is that we run multiple (identical) Docker containers of a PHP application. For validation and testing purposes we want the containers to use identical configuration (ini files, extensions, etc).

For development we want to enable debugging (in various modes and configurations), so we do that by setting XDEBUG_MODE and XDEBUG_CONFIG environment variables for the various containers. It would be really useful (for us at least) if we could set the trigger mode via an environment variable, so that we do not have to build a dedicated container just to set that one configuration.


2023-07-04 16:18

administrator   ~0006578

I think you can already do this by using environment variables in PHP.ini files. This isn't a feature that lots of people know about, but you can set the following in 99-xdebug.ini (or similar) for example:

$ php --ini
Configuration File (php.ini) Path: /usr/local/php/8.2dev/lib
Loaded Configuration File:         /usr/local/php/8.2dev/lib/php.ini
Scan for additional .ini files in: /usr/local/php/8.2dev/lib/conf.d
Additional .ini files parsed:      /usr/local/php/8.2dev/lib/conf.d/20-mongodb.ini,
$ cat /usr/local/php/8.2dev/lib/conf.d/99-xdebug.ini
xdebug.start_with_request = ${PHP_XDEBUG_START_WITH_REQUEST}
$ XDEBUG_MODE=debug,develop PHP_XDEBUG_START_WITH_REQUEST=default php -r 'echo ini_get("xdebug.start_with_request"), "\n";'
$ XDEBUG_MODE=debug,develop PHP_XDEBUG_START_WITH_REQUEST=yes php -r 'echo ini_get("xdebug.start_with_request"), "\n";'
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).

Would that work in your case too?


2023-07-05 09:51

reporter   ~0006584

Hi Derick, thanks for the reply! I never did realize that you can use environment variables in .ini files.

Yes, I think this would work for my use-case, but only if the absence of the environment variable wouldn't cause any problems. What happens if environment variable ''PHP_XDEBUG_START_WITH_REQUEST'' is not defined in your example? ''${PHP_XDEBUG_START_WITH_REQUEST}'' would yield an empty value, so will this cause xdebug to use the 'default' value then?

In the end, I think it would be better if PHP would allow setting defaults, such as this:

''xdebug.start_with_request = ${PHP_XDEBUG_START_WITH_REQUEST:default}''

But of course that is an PHP issue, not an xdebug issue.


2023-07-10 10:34

administrator   ~0006586

I think this would work for my use-case, but only if the absence of the environment variable wouldn't cause any problems.

It looks like if it is empty (or absent) it is interpreted as "no":

$ XDEBUG_MODE=debug,develop php --ri xdebug | grep start_with_request
xdebug.start_with_request => no => no

Let me see if I can "fix" PHP here...


2023-07-10 15:34

administrator   ~0006587

Looks like there was already a PR to implement this in PHP: — I'll chase up on this one, as it's better than the PR that I spent time on :-/.


2023-09-04 11:06

administrator   ~0006647

As the linked PHP PR has now been merged, I am closing this ticket. It will be in PHP 8.3!


2023-09-04 11:26

reporter   ~0006648

Thank you derick! Your suggested solution has been working great for us. And the default config values PR for PHP 8.3 would make it even better :-)

Thank you for the great work on XDebug!

Issue History

Date Modified Username Field Change
2023-04-12 12:34 Leon New Issue
2023-04-12 12:34 Leon File Added: 2023-04-12_14:23:58.png
2023-04-12 12:34 Leon File Added: 2023-04-12_14:31:07.png
2023-05-24 16:09 derick Severity minor => feature
2023-05-24 16:09 derick Status new => feedback
2023-05-24 16:09 derick Target Version => 3.2dev
2023-05-24 16:09 derick Note Added: 0006562
2023-05-24 16:19 Leon Note Added: 0006564
2023-05-24 16:19 Leon Status feedback => new
2023-07-04 16:18 derick Assigned To => derick
2023-07-04 16:18 derick Status new => feedback
2023-07-04 16:18 derick Note Added: 0006578
2023-07-05 09:51 Leon Note Added: 0006584
2023-07-05 09:51 Leon Status feedback => assigned
2023-07-10 10:34 derick Note Added: 0006586
2023-07-10 15:34 derick Note Added: 0006587
2023-09-04 11:06 derick Status assigned => resolved
2023-09-04 11:06 derick Resolution open => no change required
2023-09-04 11:06 derick Note Added: 0006647
2023-09-04 11:26 Leon Note Added: 0006648