-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathbootstrap.php
36 lines (31 loc) · 1.26 KB
/
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
30
31
32
33
34
35
36
<?php declare(strict_types=1);
/**
* The file is part of inhere/console
*
* @author https://github.com/inhere
* @homepage https://github.com/inhere/php-console
* @license https://github.com/inhere/php-console/blob/master/LICENSE
*/
error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('Asia/Shanghai');
spl_autoload_register(function ($class): void {
$file = null;
if (0 === strpos($class, 'Inhere\Console\Examples\\')) {
$path = str_replace('\\', '/', substr($class, strlen('Inhere\Console\Examples\\')));
$file = dirname(__DIR__) . "/examples/$path.php";
} elseif (0 === strpos($class, 'Inhere\ConsoleTest\\')) {
$path = str_replace('\\', '/', substr($class, strlen('Inhere\ConsoleTest\\')));
$file = __DIR__ . "/$path.php";
} elseif (0 === strpos($class, 'Inhere\Console\\')) {
$path = str_replace('\\', '/', substr($class, strlen('Inhere\Console\\')));
$file = dirname(__DIR__) . "/src/{$path}.php";
}
if ($file && is_file($file)) {
include $file;
}
});
if (is_file(dirname(__DIR__, 3) . '/autoload.php')) {
require dirname(__DIR__, 3) . '/autoload.php';
} elseif (is_file(dirname(__DIR__) . '/vendor/autoload.php')) {
require dirname(__DIR__) . '/vendor/autoload.php';
}