PHP: Guides and Practical Know-how | Page 14 | mironsoft Blog
PHP
-
Oct 26, 2025
Anyone who does not deliberately test exceptions leaves error handling unverified, which is the most dangerous blind spot in a PHP test suite. PHPUnit provides precise methods to ensure that the correct exception type, the right message, and the correct error code are actually raised.
-
Oct 22, 2025
A PHP object without a single property still occupies several dozen bytes in memory, purely from the internal zend_object header. Anyone seeing unexpectedly high memory usage with thousands of objects per request usually finds the cause in the interplay of object header, property table and the size of typed properties, not in the actual payload.
-
Oct 21, 2025
An abstract class and an interface appear at first glance to solve a similar problem, namely defining a contract that concrete classes must follow. The decisive difference lies in what each construct actually brings along: an interface is a pure contract with zero implementation, an abstract class, on the other hand, can contain constructors, shared state, and concrete methods that every subclass inherits automatically. This article uses a running report generator example to show when each tool is the right choice, why PHP's single inheritance restriction shapes this decision decisively, and how both concepts work together cleanly in a single class hierarchy.
-
Oct 21, 2025
Anyone who wants to refactor legacy code without tests faces a chicken-and-egg problem: writing tests requires understanding the code, understanding requires reading the code, but confidence when changing it requires tests. Golden Master tests untangle this knot, they test the behavior before it is understood.
-
Oct 20, 2025
A Magento project with 40 third-party modules quickly accumulates hundreds of transitive dependencies. If you do not know which packages constrain each other before a Composer update, you lose hours to trial and error. PhpStorm makes this graph visible.
-
Oct 19, 2025
Hashing passwords with MD5 or SHA-1 leaves the door wide open for brute-force and rainbow-table attacks the moment a database leaks. This article explains how bcrypt and Argon2id actually work, how to use PHP's password_hash() correctly in production code, and which mistakes around salts, cost factors, and rehashing happen most often in real-world applications.
-
Oct 19, 2025
A network error after a successful payment leads, without protection, to the client repeating the same request and triggering a second payment. This article shows how idempotency keys are implemented in PHP APIs to reliably prevent exactly this problem, including request fingerprinting, response caching, and protection against race conditions.
-
Oct 19, 2025
Composer can do far more than just install dependencies: through Composer scripts and lifecycle hooks, every step of the installation process, from the very first composer install to the last autoload dump, can be extended with custom automation. Whether a shell command or a PHP callback via Composer\Script\Event, anyone who knows the complete event list replaces manual setup steps, forgotten cache clears, and improvised onboarding instructions with reproducible, versioned automation right inside composer.json.
-
Oct 17, 2025
A persistent data structure keeps its old version fully intact after every change and produces a new version instead, without copying the entire content. In PHP 8.4 this principle can be implemented directly with immutable linked lists and structural sharing, with no external library required.
-
Oct 17, 2025
Two independently deployable PHP services communicating over an API can each have a fully green test suite and still become incompatible. Contract tests with PHPUnit close exactly this gap between provider and consumer.