1
0
Fork 0
composer/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php

43 lines
1.1 KiB
PHP
Raw Normal View History

<?php
// autoload.php generated by Composer
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
require __DIR__ . '/composer' . '/ClassLoader.php';
}
return call_user_func(function() {
$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(function($class) {
2012-04-23 08:56:46 +00:00
$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';
2012-06-11 12:15:08 +00:00
if (!$path = stream_resolve_include_path($path)) {
return false;
}
2012-06-11 12:15:08 +00:00
require $path;
2012-05-22 10:07:08 +00:00
return true;
}
});
$loader->register();
return $loader;
});