PHP: Guides and Practical Know-how | Page 28 | mironsoft Blog
PHP
-
Feb 25, 2025
Example-based tests only check the cases a developer happened to think of. Property-based testing flips the approach around: instead of concrete inputs, you formulate invariants, properties that must hold for every conceivable input, and let the library search for thousands of random counterexamples.
-
Feb 25, 2025
Global variables and singletons feel convenient, yet they make PHP code hard to test, hard to parallelize and unpredictable in large projects. This article shows how to replace Singleton::getInstance(), $GLOBALS and static registries with dependency injection step by step, without rebuilding the whole application at once.
-
Feb 23, 2025
Xdebug can do far more than pause execution on a line. With the modes trace, profile, coverage and gcstats, Xdebug opens an analysis window into the real runtime state of a PHP request: call hierarchies with timestamps, cachegrind profiles for self time and inclusive time, a coverage API for custom analysis tools, and garbage collection statistics that normally stay completely hidden.
-
Feb 23, 2025
Code reviews without context cost time and produce surface level nitpicking. PhpStorm provides the tools to prepare reviews in a structured way through Git diffs, File History, the Annotate view and the TODO tracker, without ever leaving the editor and without relying on the GitHub UI as the only source of context.
-
Feb 22, 2025
With debug_backtrace(), a PHP script can inspect its own call stack at runtime and find out who called a function from where. This form of metaprogramming is the foundation of custom deprecation warnings, automatic loggers with file and line info, and simple access controls for internal APIs.
-
Feb 19, 2025
When creating new objects is expensive, the Prototype Pattern copies an existing prototype instead. How Magento uses clone() and Factory::create(), and when you should apply it yourself.
-
Feb 19, 2025
Every grown PHP project accumulates technical debt, the question is never whether but which item should be fixed first. This article shows a practical method for scoring technical debt by change frequency, risk of failure and fix effort, and deriving a defensible order from it.
-
Feb 18, 2025
For years, developers reached for a private property plus a public getter just to allow read access from the outside, without opening up write access. Asymmetric Visibility ends that detour: a property can be publicly readable and privately or protected writable at the same time, directly in the declaration, without a single line of getter code.
-
Feb 17, 2025
Choosing the right authentication mechanism decides the security and integration effort of a PHP API. This article shows when API keys are enough, how JWT signatures really work, and when the extra effort of OAuth2 truly pays off, with secure storage and full code examples.
-
Feb 15, 2025
A trait copies real method bodies straight into a class, an interface only promises those methods exist, without shipping a single line of implementation. Anyone who mixes traits and interfaces, or swaps one for the other, loses exactly the sharpness that makes object-oriented design robust: horizontal reuse of behavior on one side, binding contracts for polymorphism and testability on the other.