Strategy is one of those patterns that seems like unnecessary complexity on first contact. Why wrap a single algorithm in a separate class? The value only becomes clear with a second and third algorithm – when instead of a growing if-else you have clean, interchangeable code. I show how it works in PHP and where Magento 2 uses this pattern without you realising it.

(more…)

One of the most common questions when working with Magento 2 is: should I override a class with a preference, or use a plugin? The answer is almost always the same – use a plugin. But “almost” does a lot of work here. I explain the differences and show when a preference makes sense.

(more…)

Everyone starts with var_dump() and die(). But after a few years working with PHP and Magento 2, those methods start to hurt – especially when debugging a complex order flow with dozens of plugins. I show how to set up Xdebug and why it is worth doing once, properly.

(more…)

PHP 7.2 was released in November 2017, but in practice many projects are only migrating to this version now. If you are still on 7.0 or 7.1 – this post is for you. I go through the most important changes that have a real impact on everyday code.

(more…)

TOP