DEV Community

Asrar
Asrar

Posted on

7

Magento PHPStorm conditional debugging

Conditional debugging is an useful feature in PHPStorm.
This can become very handy when you would want your breakpoint to fire-up when a certain condition is met for instance - in an iteration.

I was debugging vendor/magento/module-customer/Model/Customer/DataProvider.php::getAttributesMeta(). But I really didn't want the debugger to stop on every single customer attributes in the following code:

foreach ($attributes as $attribute) {
$this->processFrontendInput($attribute, $meta);
$code = $attribute->getAttributeCode();
....

Instead, all I wanted is, something like - hey debugger, when $code == "group_id", show me what's happening at that point.

To, achieve this, I set a condition on the breakpoint on line $code = $attribute->getAttributeCode(); like below:

PHPStorm Conditional Debugging

And that's it, now my debugger fires up only when attribute code is group_id.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay