-
Notifications
You must be signed in to change notification settings - Fork 3
/
autoload.php
39 lines (32 loc) · 1.11 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
<?php
switch (true) {
case file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'):
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
break;
case file_exists(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php'):
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php';
break;
default:
requeirFiles( __DIR__ . DIRECTORY_SEPARATOR . 'src');
break;
}
/**
* @param string $path
*/
function requeirFiles(string $path)
{
$iterator = new DirectoryIterator($path);
while ($iterator->valid()) {
$item = $iterator->current();
if (!$item->isDot()) {
if ($item->isFile()) {
require_once $path . DIRECTORY_SEPARATOR . $item->getFilename();
} elseif ($item->isDir()) {
requeirFiles($item->getPathname());
}
}
unset($item);
$iterator->next();
}
unset($iterator);
}