-
Notifications
You must be signed in to change notification settings - Fork 68
/
autoload.php
53 lines (40 loc) · 1.35 KB
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require __DIR__ . '/src/Jit/ClassLoader.php';
use Kahlan\Jit\ClassLoader;
return function ($basePath) {
$import = function($loader, $basePath) {
if (!file_exists("{$basePath}/autoload.php")) {
return [];
}
$map = require "{$basePath}/composer/autoload_namespaces.php";
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require "{$basePath}/composer/autoload_psr4.php";
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require "{$basePath}/composer/autoload_classmap.php";
if ($classMap) {
$loader->addClassMap($classMap);
}
if (file_exists("{$basePath}/composer/autoload_files.php")) {
return require "{$basePath}/composer/autoload_files.php";
}
return [];
};
$loader = new ClassLoader();
$files = [];
if (!$absolute = realpath(__DIR__ . '/../../autoload.php')) {
$absolute = realpath(__DIR__ . '/vendor/autoload.php');
}
if ($absolute) {
$files += $import($loader, dirname($absolute));
}
if (realpath(getcwd()) !== realpath(__DIR__)) {
$files += $import($loader, $basePath);
}
$loader->register(true);
$loader->files($files);
return $loader;
};