-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
29 lines (21 loc) · 895 Bytes
/
bootstrap.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
<?php
spl_autoload_register(
function ($classNameSpace) {
$classNameSpace = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, str_replace('\\', DIRECTORY_SEPARATOR, $classNameSpace)));
foreach ($classNameSpace as $key => $value) {
if (empty($value) || $value == '.' || $value == '..') {
unset($classNameSpace[$key]);
}
}
$classPath = __DIR__.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $classNameSpace).'.php';
if (file_exists($classPath)) {
require_once $classPath;
return;
}
$classPath = __DIR__.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $classNameSpace).'.php';
if (file_exists($classPath)) {
require_once $classPath;
return;
}
}
);