Create a conditional breakpoint in PhpStorm with Xdebug
Learn how to set up conditional breakpoints in PhpStorm with Xdebug to pause execution only when specific conditions are met.
Fresh bytes every Thursday. No spam, ever. Unsubscribe anytime.
Join 9,000+ developers and get three free video lessons every week.
Conditional breakpoints are regular breakpoints with a twist – they only pause execution when specific conditions are met. They're incredibly useful when debugging loops, or when you only care to debug certain scenarios.
Let's use a real-world example. Say we're processing orders and only want to debug those over $100:
We want to set a breakpoint in the processOrders
function on the line updateOrderStatus($order, $total);
Here's how to set up your conditional breakpoint:
- Click in the left gutter to create a regular breakpoint
- Right-click the red breakpoint dot
- Enter
$total > 100
in the "Condition" field
That's it! The debugger will now only pause when an order's total exceeds $100.
PhpStorm lets you use any valid PHP expression as your condition, with a few limitations:
- Keep expressions to a single line
- No variable assignments
- Simple expressions work best
Here are some practical examples you might find useful: