DEV Community

Asrar
Asrar

Posted on

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.

Top comments (0)