4

Is it possible to set a "PHP Exception Breakpoint" inside of PhpStorm debugger so that it triggers each time a specific variable is used?

For example I have a $_GET['foo'] in request and want debugger to pause every time the variable $_GET['foo'] is used in code.

2
  • Nope. AFAIK none of the debuggers supported by PhpStorm (xdebug & zend debugger) support such kind of breakpoints. You can put conditions on breakpoints but not auto-break on certain variable access. Commented Jul 22, 2015 at 12:09
  • A "breakpoint at variable use" is called a watchpoint. JetBrains' CLion IDE does support watchpoints. Commented Aug 2, 2021 at 14:59

1 Answer 1

3

Exception breakpoints only trigger when an error has occurred, so the short answer is "no."

However, you can right-click (or control+click, for Mac) the top folder in your source tree in the project file browser and choose "Find in Path" to locate all instances of $_GET['foo']. Once you know where they all are, create normal breakpoints in the usual way. Then put them into a "group," according to your intentions for those breakpoints:

  1. Create breakpoints everywhere $_GET['foo'] is referenced, using the "Find in Path..." feature of the project file browser to search for them globally (Find the main folder of your project; then Right-click for PC or [Control]+[Click] for Mac to find this option).
  2. Once your breakpoints are set everywhere you find $_GET['foo'], click Run > View Breakpoints to show them in a list.
  3. Select all of the corresponding breakpoints using [Command]+[Click] or [Shift]+[Click] to select multiple entries, if necessary.
  4. Right-click or [Control]+[Click] your group of selected breakpoints in the list (or just an individual breakpoint, if you like) and choose Move to group. If you do not have any groups made up yet, just choose Create group to make a new one.

In the View Breakpoints screen, you can then enable or disable the entire breakpoint group by checking its box. When that group and its breakpoints are no longer needed, you can delete a group by clicking the [-] minus button.

Sign up to request clarification or add additional context in comments.

1 Comment

I see. And thanks for mentioning the grouping feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.