Composer autoloader class map and PHP runtime resolution precedence
0 reputation · 09 Aug 2023, 17:38 UTC
The goal is to clarify how Composer’s autoloading configuration interacts with PHP runtime class resolution when optimized class maps, PSR-4 and PSR-0 rules coexist for the same code base.
The integration boundary involves Composer generating static maps and PSR rules that PHP’s SPL autoloader consumes at request time. There is uncertainty about precedence when multiple autoload definitions can resolve the same fully qualified class name, and about how the APCu autoloader feature changes resolution behavior versus caching results. A decision point is whether optimization is warranted without first confirming that filesystem lookups are a measurable bottleneck in the specific runtime.
What is the documented precedence order between class map entries, PSR-4 mappings and PSR-0 mappings when overlapping definitions exist?
Does enabling the APCu autoloader alter precedence or only cache the outcome of the existing resolution order?
Under which conditions does an optimized class map take precedence over a PSR-4 namespace lookup during PHP runtime autoloading?