PHP: Guides and Practical Know-how | Page 31 | mironsoft Blog
PHP
-
Jan 22, 2025
As soon as a system needs to interchangeably create multiple objects that belong together, for instance payment providers with a matching client, validator and logger, a simple factory method is no longer enough. The Abstract Factory pattern encapsulates exactly this creation of entire product families behind a shared, type-safe interface.
-
Jan 17, 2025
Anyone who still references methods and functions through strings like 'strlen' or arrays like [$object, 'method'] gives up type checking, IDE refactoring, and reliable visibility checks. First-class callable syntax turns those references into real, parser-resolved expressions and closes one of the last string-based gaps in the language.
-
Jan 16, 2025
Password hashing directly determines how expensive it is for an attacker to crack each individual password after a database leak. Argon2id is now considered the preferred algorithm because it is memory-intensive and therefore resistant to GPU- and ASIC-backed attacks, while bcrypt with its CPU-bound cost function has worked as a solid standard for decades. This article shows how to correctly configure, salt, pepper, and migrate both algorithms in production using the PHP standard API password_hash() and password_verify().
-
Jan 16, 2025
Starting Composer and npm from scratch costs minutes on every single build. The good news is that both package managers ship with robust local caches that can persist across Docker builds without inflating the image size. The key lies in correctly separating the lock file layer, the vendor layer and the cache mount, and in understanding which cache type is the right one for each situation.
-
Jan 15, 2025
PhpStorm refactorings are powerful but not infallible. Rename works excellently in statically typed contexts, but fails with Magento magic methods. Extract Method produces clean code, but can surprise you with closures and generators. An honest look at what is safe and what requires thorough manual review.
-
Jan 15, 2025
A deployment that works on a developer's machine but fails in production with a different package version can usually be traced back to a missing or mishandled composer.lock file. Anyone who understands how Composer builds hashes, how platform config influences resolution, and how merge conflicts arise in the lock file, builds PHP applications that install exactly the same package versions in every environment.
-
Jan 14, 2025
Tests that pass individually but fail when run together are the most frustrating problem in a PHPUnit suite. Behind them almost always lies global state, missing isolation, or hidden dependencies between tests, problems that are discoverable and permanently fixable with the right methodology.
-
Jan 6, 2025
Until PHP 8.0, every default value had to be a constant expression, a new object instance as a default simply was not allowed. Since PHP 8.1, new can stand directly in initializers, in parameters, attribute arguments, and property declarations, making a whole catalog of workarounds unnecessary.
-
Jan 6, 2025
A correctly configured PhpStorm environment for Magento 2 saves hours every day: a Docker interpreter for precise code completion, Xdebug without manual steps, CLI runners for Magento commands right inside the IDE, and file templates that create new ViewModels, plugins and repositories in seconds.
-
Jan 5, 2025
Anyone maintaining a library or tool for multiple PHP or Node versions can hardly avoid test matrices. This article shows how parallel: matrix: in GitLab CI turns a single job definition into several parallel test runs, and how to balance runtime cost against test coverage.