54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
// autoload.php generated by Composer
|
|
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
|
|
require __DIR__ . '/composer' . '/ClassLoader.php';
|
|
}
|
|
|
|
if (!class_exists('ComposerAutoloaderInitTargetDir', false)) {
|
|
class ComposerAutoloaderInitTargetDir
|
|
{
|
|
public static function getLoader()
|
|
{
|
|
$loader = new \Composer\Autoload\ClassLoader();
|
|
$composerDir = __DIR__ . '/composer';
|
|
|
|
$map = require $composerDir . '/autoload_namespaces.php';
|
|
foreach ($map as $namespace => $path) {
|
|
$loader->add($namespace, $path);
|
|
}
|
|
|
|
$classMap = require $composerDir . '/autoload_classmap.php';
|
|
if ($classMap) {
|
|
$loader->addClassMap($classMap);
|
|
}
|
|
|
|
spl_autoload_register(array('ComposerAutoloaderInitTargetDir', 'autoload'));
|
|
|
|
$loader->register();
|
|
|
|
return $loader;
|
|
}
|
|
|
|
public static function autoload($class)
|
|
{
|
|
$dir = dirname(__DIR__) . '/';
|
|
$prefixes = array('Main\\Foo', 'Main\\Bar');
|
|
foreach ($prefixes as $prefix) {
|
|
if (0 !== strpos($class, $prefix)) {
|
|
continue;
|
|
}
|
|
$path = $dir . implode('/', array_slice(explode('\\', $class), 2)).'.php';
|
|
if (!$path = stream_resolve_include_path($path)) {
|
|
return false;
|
|
}
|
|
require $path;
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return ComposerAutoloaderInitTargetDir::getLoader();
|