View Issue Details

IDProjectCategoryView StatusLast Update
0001921XdebugStep Debuggingpublic2021-01-04 00:46
Reporterngocphamm Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version3.0.1 
Target Version3.0devFixed in Version3.0.2 
Summary0001921: Xdebug does not start step debugging if start_with_request=trigger
DescriptionI have looked through the documentation and want to only trigger Xdebug step debugging with environment variable, so I tried this

[PHP.INI]
xdebug.mode=debug
xdebug.start_with_request=trigger
xdebug.trigger_value=killdabugs
xdebug.log=/usr/local/var/log/xdebug.log

And I have a ZSH function so I can call "phpdebug script.php" to trigger debugging

function phpdebug() {
  export XDEBUG_SESSION=killdabugs
  export XDEBUG_TRIGGER=killdabugs

  php $1

  unset XDEBUG_SESSION
  unset XDEBUG_TRIGGER
}

This doesn't seem to work. If I set "start_with_request=yes" then it will, but it always do step debugging, and that's not what I want.
Steps To Reproduce1. Install php using homebrew "brew install php"
2. Install xdebug using homebrew tap shivammathur/extensions "brew install xdebug@8.0"
3. Configure xdebug as above
4. Try step debugging with a PHP script with ZSH function "phpdebug script.php"
5. Doesn't work if "start_with_request=yes"
TagsNo tags attached.
Operating SystemmacOS Catalina 10.15.7
PHP Version8.0.0-8.0.4

Relationships

has duplicate 0001923 closedderick CLI session starts ignoring is there XDEBUG_SESSION env. variable 

Activities

ngocphamm

2020-12-24 20:51

reporter   ~0005615

I'm not sure if installing xdebug from that homebrew tap would make any differences, but I also failed to install xdebug with pecl. I used to be able to before version 3.0.0.

yched

2020-12-25 12:39

reporter   ~0005616

SAme here, I tried the same set up and struggled on the same behavior : that's because the presence of XDEBUG_TRIGGER is checked in the $_ENV superglobal (through find_in_globals()), and that only includes env vars set from the command line if the 'variables_order' ini param contains 'E', which apparently is not the case by default

All other settings mentioned in the docs as being read fron the env (XDEBUG_MODE, XDEBUG_CONFIG...) are checked using getenv(), which works whatever the value of the 'variables_order' param.

So passing XDEBUG_MODE, XDEBUG_CONFIG through the CLI env always works, but not XDEBUG_TRIGGER, which is confusing and not very clear from the docs.
It also makes the start_with_request=trigger setting pretty much useless for CLI, since you cannot easily set the trigger manually in a command.

yched

2020-12-25 12:45

reporter   ~0005617

FWIW, as a workaround for CLI I ended up doing :
--- xdebug.ini
xdebug.mode=develop
xdebug.start_with_request=yes
--- shell helper
function xdebug() {
  XDEBUG_MODE="develop,debug" "$@"
}

But I'd find it much cleaner to go with
--- xdebug.ini
xdebug.mode=develop,debug
xdebug.start_with_request=trigger
--- shell helper
function xdebug() {
  XDEBUG_TRIGGER=1 "$@"
}
as mentioned in the OP - if that worked ;-)

ngocphamm

2020-12-25 13:47

reporter   ~0005618

I found that the workaround yched provided works for the same purpose (thanks!), but I agreed that the trigger should have worked as documented.

derick

2021-01-04 00:45

administrator   ~0005632

https://github.com/xdebug/xdebug/pull/718

Issue History

Date Modified Username Field Change
2020-12-24 20:50 ngocphamm New Issue
2020-12-24 20:51 ngocphamm Note Added: 0005615
2020-12-25 12:39 yched Note Added: 0005616
2020-12-25 12:45 yched Note Added: 0005617
2020-12-25 13:47 ngocphamm Note Added: 0005618
2020-12-31 11:49 derick Target Version => 3.0dev
2021-01-04 00:45 derick Assigned To => derick
2021-01-04 00:45 derick Status new => closed
2021-01-04 00:45 derick Resolution open => fixed
2021-01-04 00:45 derick Fixed in Version => 3.0.2
2021-01-04 00:45 derick Note Added: 0005632
2021-01-04 00:46 derick Relationship added has duplicate 0001923