PHP: Guides and Practical Know-how | Page 27 | mironsoft Blog
PHP
-
Mar 20, 2025
Anyone who tests HTTP clients only with real API calls ends up with slow, fragile tests that turn red the moment the network hiccups. Guzzle's MockHandler, response stacks and custom HTTP adapters give you full control over every response scenario, success, timeout, server outage and retry cascade, directly inside PHPUnit, deterministic and fast.
-
Mar 19, 2025
Tests that depend on the current time, randomly generated UUIDs, or pseudo-random values are flaky: they sometimes fail and sometimes don't, and the cause is hard to reproduce. Clock interfaces, UUID factories, and controlled randomness solve this problem at its root, without complicating the production code.
-
Mar 16, 2025
OPcache's factory defaults were designed for a developer laptop, not a PHP-FPM pool under heavy load. If you have never touched memory_consumption, max_accelerated_files, or validate_timestamps, you are leaving measurable response time on the table and risking wasted memory, hash collisions, and unnecessary filesystem stats on every single request. This guide walks through the OPcache Tuning parameters that genuinely have measurable impact, how to size them correctly, and what a safe zero downtime deployment workflow looks like around them.
-
Mar 12, 2025
Recurring checks like if ($logger !== null) quickly spread across an entire codebase and hide the actual business logic behind defensive programming. The Null Object pattern replaces missing objects with a neutral object of the same interface that simply does nothing, instead of forcing a conditional branch.
-
-
Mar 9, 2025
Most applications store only the current state of an entity and overwrite it on every change, permanently losing any information about how that state came to be. Event sourcing turns this principle around: instead of the current state, it stores the complete, immutable sequence of every event that led to that state, from which the current state can be recomputed at any time.
-
Mar 8, 2025
Since PHP 8.1, individual properties can be declared readonly. Since PHP 8.2, an entire class can be made immutable in one step. The difference is more than syntactic sugar: a readonly class is a class level design decision, with its own rules for inheritance, dynamic properties, and migrating existing value objects.
-
Mar 6, 2025
A single list query followed by one query per item inside a loop looks harmless during development, yet turns into hundreds or thousands of database calls per page request under production load. This article shows how to spot the N+1 query problem in ORM and collection code, fix it with eager loading and batch queries, and keep it from returning with profiling tools.
-
Mar 6, 2025
For years, PHP developers wrote a pair of getX() and setX() methods for every validated or computed property. Property Hooks move that logic directly into the property declaration itself, with get and set hooks that behave like plain fields for callers while keeping full control over reads and writes.
-
Mar 6, 2025
If you only find out about quality gates in the CI pipeline, you lose minutes or hours on feedback loops that could have been resolved locally in seconds. PHPStan, PHPUnit, PHPCS and Rector can be integrated into PhpStorm so that errors become visible right at the moment you save, without ever leaving the command line.