-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathbootstrap.php
More file actions
27 lines (27 loc) · 940 Bytes
/
bootstrap.php
File metadata and controls
27 lines (27 loc) · 940 Bytes
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
<?php
/**
* @Author bigbigant
* This script is to initialize autoloading for QPM examples and Tests.
* Composer autoload.php(/vendor/autoload.php) is the first choice.
* If there is no composer file, a simple autoloader would be registered, but some features depend 3rd party packages may not be usable.
*/
$autoloadFile = __DIR__.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
if (is_file($autoloadFile)) {
require $autoloadFile;
} else {
spl_autoload_register(
function ($class) {
$prefix = 'Comos\\Qpm\\';
$baseDir = __DIR__ . DIRECTORY_SEPARATOR. 'src';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relativeClass = substr($class, $len);
$file = $baseDir .DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php';
if (file_exists($file)) {
require $file;
}
}
);
}