DDEV works great day to day, but what if you need a custom configuration DDEV does not support? Or you want to understand what is happening under the hood? I show how to build a PHP environment from scratch with pure Docker and docker-compose – nginx, PHP-FPM, MySQL and Redis with no intermediate tools.
PHP array is versatile enough that we rarely need other data structures. But a doubly linked list has properties an array does not – inserting and removing elements from the middle in O(1), without shifting the remaining elements. I implement one from scratch in PHP and show when it is worth reaching for.
Magento 2.3 introduced GraphQL as an alternative to the REST API. Where REST requires separate endpoints for each resource, GraphQL lets the client decide what data it needs in a single query. I show how to write a custom resolver and expose data through GraphQL in a Magento 2 module.
PHP 7.4 was released in November 2019. After migrating several Magento 2 modules to the new version I have a clear picture. Typed properties genuinely affect the way you write classes – but they also have pitfalls worth knowing. I show what works great, what surprises you, and what migration looks like in practice.
The new operator in production code is a warning sign. A class that directly instantiates other classes is tightly coupled to them – hard to test, hard to extend. Factory Method delegates the responsibility for object creation to dedicated classes. In Magento 2 factories are everywhere – and generated automatically.
Operations like sending emails, syncing with an ERP, or recalculating indexes do not have to block an HTTP request. Magento 2 has a built-in Message Queue Framework that lets you push such tasks to an asynchronous queue. I show how it works with RabbitMQ and how to write your own publisher and consumer.
A PHP array is one of the most-used data types, but few people think about how it works under the hood. A PHP array is actually a hash table – a data structure that allows O(1) element access. I show how it works, what the practical implications are, and where PHP arrays surprise you with their performance characteristics.
PHP 7.4 arrives in November 2019 and brings several changes that will have a real impact on everyday code. Typed properties are the headline feature – at last we can declare types directly on class properties. Plus arrow functions, spread in arrays, and the null coalescing assignment operator.
Inheritance is the simplest way to extend a class – but not always the best. When you want to add several independent features to an object, a class hierarchy quickly becomes unreadable. Decorator lets you wrap objects in layers of functionality without modifying the original and without deep inheritance.
Dependency Injection in Magento 2 looks like magic at first. You type an interface in the constructor and Magento delivers the right implementation. How does it know what to inject? How does DI compilation work? What are virtual types and what are they for? I break it all down.
