alexey-kupershtokh/lazy-apc-class-loader

1.1.0 2014-10-12 23:32 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:59:37 UTC


README

此包受到了Symfony2 ClassLoader组件的极大启发。

但从性能角度来看,它应该表现得更好:它不需要最初加载composer的自动加载器,这对于ApcClassLoader的正常工作是必要的。相反,LazyApcClassLoader在很多情况下可以独立工作,并在缓存未命中时仅作为回退使用composer的一个。通常,只需要加载1个文件而不是8个。

安装

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

使用方法

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();

基准测试

https://github.com/AlexeyKupershtokh/AutoLoadBenchmark