PHP's PDO extension has lacked a formal interface for nearly 20 years, forcing the ecosystem into fragmented workarounds: inheritance-based lazy loaders, abandoned packages, and incompatible abstractions across libraries like Aura.Sql and Doctrine DBAL. The post proposes a minimal PdoInterface that mirrors PDO's existing public API, demonstrates a clean lazy-loading proxy implementation using composition, and outlines a non-breaking migration path via PHP union types. Two standardization routes are explored: a PHP-FIG PSR (analogous to PSR-3 for loggers or PSR-7 for HTTP messages) and a native language-level interface (similar to DateTimeInterface), which are not mutually exclusive.
Table of contents
The Problem with a Concrete Class #The Workarounds Are Not Pretty #The Ecosystem Has Noticed #A Minimal Interface #A Proxy as a Reference Implementation #What the Interface Unlocks #A Non-Breaking Path Forward #A PSR or a Language Feature? #An Invitation #Sort: