← Alle berichten

Loading Composer without loading Composer

Phlo no longer requires vendor/autoload.php at boot. It registers a thin wrapper instead, and Composer is pulled in only when a class miss actually needs it.

Most requests in a Phlo app never touch a Composer package. The engine resolves its own classes from its classmap, and plenty of apps have a vendor/ directory holding one library used on one route. Requiring the autoloader on every boot pays for all of it every time.

The wrapper is registered last in the spl_autoload_register chain. When a class reaches it, the engine has already failed to find it, so this is the moment Composer becomes worth its cost: require the autoloader, then look up Composer's freshly registered ClassLoader in the chain and call loadClass() for the class that was being sought. Without that last step the miss that triggered the load would fall through unresolved, because Composer's handler registered after the lookup had already started.

There is one more move that is easy to skip. Composer registers with prepend = true, putting itself at the front of the chain. Left there, every subsequent Phlo class lookup would walk through Composer first. So it is immediately unregistered and re-registered at the back, where it belongs.

The result: apps that never touch a package never pay for one, and apps that do pay once.

Engine 1.0. See the Performance chapter.

We gebruiken essentiële cookies om deze site te laten werken. Met uw toestemming gebruiken we ook analytics om de site te verbeteren.