-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
32 lines (24 loc) · 915 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
30
31
32
<?php
/**
* Bootstrapper and autoloader
*
* Date: 3/8/18
* Time: 8:08 AM
* @author Michael Munger <[email protected]>
*/
function appAutoloader($class) {
$buffer = explode("\\", $class);
$class = end($buffer);
$baseDir = __DIR__;
$candidate_files = [];
/* If this is not a database abstraction, then it is located in the classes directory. Try that last. */
$candidate_path = sprintf($baseDir.'/classes/%s.class.php',$class);
array_push($candidate_files, $candidate_path);
/* Loop through all candidate files, and attempt to load them all in the correct order (FIFO) */
foreach($candidate_files as $dependency) {
if(file_exists($dependency) && is_readable($dependency)) require_once($dependency);
}
return ['success' => true];
}
spl_autoload_register('appAutoloader');
if(file_exists('vendor/autoload.php')) include('vendor/autoload.php');