alexey-kupershtokh/lazy-apc-class-loader

1.1.0 2014-10-12 23:32 UTC

This package is not auto-updated.

Last update: 2024-04-23 01:40:12 UTC


README

This package was heavily inspired by the Symfony2 ClassLoader component.

But it should be even better from performance point of view: It does not require composer's autoloader to be initially loaded which is necessary for the ApcClassLoader to work. Instead, LazyApcClassLoader can work alone in many cases and use composer's one only as a fallback on cache misses. Usually it's enough to load only 1 file instead of 8.

Installation

composer require alexey-kupershtokh/lazy-apc-class-loader

Usage

require_once(__DIR__ . '/vendor/alexey-kupershtokh/lazy-apc-class-loader/src/LazyApcClassLoader.php');

$loader = new \AlexeyKupershtokh\LazyApcClassLoader\LazyApcClassLoader(
    'my_prefix',
    function () {
        // init composer autoloader if ever needed
        return require_once __DIR__ . '/vendor/autoload.php';
    }
);
$loader->register();

Benchmark

https://github.com/AlexeyKupershtokh/AutoLoadBenchmark