Real Dreams
Real Dreams

Reputation: 18020

Logical breakpiont

Using Xdebug (with or without PhpStorm) how can I define a breakpoint using a logical condition instead of specifying location of breakpoint by line number. e.g. execution is needed to be stopped when $x==3 or is_null($y)'.

Upvotes: 1

Views: 45

Answers (2)

user24525
user24525

Reputation: 451

i don't know phpstorm, but with other debugger clients you could use xdebug_break() to stop the execution. just put the following snippet into your code somewhere where you $x and $y using.

if ($x==3 || is_null($y)) {
  xdebug_break();
}

see the xdebug documentation

bool xdebug_break() Emits a breakpoint to the debug client.

This function makes the debugger break on the specific line as if a normal file/line breakpoint was set on this line.

Upvotes: 0

elixenide
elixenide

Reputation: 44841

You can't. You can make a breakpoint conditional, as in "stop at line 123 only if $x==3" or "stop if an exception is thrown but only if $x==3," but you can't make a breakpoint purely conditional.

Upvotes: 2

Related Questions