setUseIncludePath(true); spl_autoload_register(array('ComposerAutoloaderInitIncludePath', 'autoload'), true, true); $loader->register(true); return $loader; } public static function autoload($class) { $dir = dirname(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; } } }