Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to run arbitrary php code while stepping through code in an xdebug session?

Tags:

php

xdebug

Just like how variables values can be changed while stepping through code lines. Is it possible to add PHP statements between lines and let it run further after picking that up change?

Probably not even possible as the state of the codebase is already loaded into memory when it starts executing but I think it was worth a try.

like image 668
Ashfame Avatar asked Nov 21 '25 19:11

Ashfame


1 Answers

Xdebug can do this. It's the exact same mechanism in the DBGp protocol as updating variables. This happens with the DBGp "eval" command, which as you can guess, runs PHP's eval function.

But it depends on the IDE whether they actually have implemented this. PhpStorm for example has its console, which is also a wrapper for this eval command. You can probably get away by using a real PHP statement in a "watch" as well.

like image 135
Derick Avatar answered Nov 23 '25 08:11

Derick