Visitor pattern – double dispatch, CSV/PDF export, validation without modifying classes
Visitor is one of the less commonly used GoF patterns, but it solves a specific problem elegantly: adding new operations to an object hierarchy without modifying the hierarchy itself. Double dispatch – calling different methods based on both the visitor type and the element type – is the mechanism. I show a PHP implementation and apply it to a real scenario: exporting product data to CSV and PDF without adding export logic to the product classes.
- Published in Wzorce projektowe
Hyvä Theme – architecture, Alpine.js, Tailwind, PHTML templates, events
Hyvä Theme has become the default choice for new Magento 2 projects. It replaces the Knockout.js and RequireJS stack with Alpine.js and Tailwind CSS, keeping templates in standard PHP/PHTML with no build step for JavaScript. The result is dramatically simpler frontend code and Lighthouse scores that Luma could never reach. I show the architecture and how development actually differs from Luma.
- Published in Magento / Adobe Commerce
PHP 8.4 preview – property hooks, asymmetric visibility, chaining new
PHP 8.4 is due in November 2024 and its headline features address two long-standing awkwardnesses. Property hooks allow computed and validated properties without getter/setter boilerplate. Asymmetric visibility lets you expose a property publicly for reading but restrict writing to the class. Chaining on new without parentheses removes a syntactic annoyance. I preview all three with practical examples.
- Published in PHP
Checkout customisation – custom fields, JS mixin, step, save to Order
Customising the Magento 2 checkout is one of the most requested – and most feared – development tasks. The checkout is a JavaScript-heavy single-page application built on Knockout.js and RequireJS. Adding custom fields, new steps, or modifying the order of existing ones requires understanding the JS architecture alongside the PHP backend. I show a complete example: custom delivery note field from frontend to Order.
- Published in Magento / Adobe Commerce
