-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautoload.php
More file actions
33 lines (31 loc) · 766 Bytes
/
autoload.php
File metadata and controls
33 lines (31 loc) · 766 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
28
29
30
31
32
33
<?php
$path = "";
if(isset($_SERVER['REQUEST_URI'])){
$path = $_SERVER['REQUEST_URI'];
//get $path except first "/"
$path = substr($path, 1);
//remove string from start to second "/"
$path = substr($path, strpos($path, "/") + 1);
}else{
$path = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
}
define('PATH',$path);
define('BASE_DIR',__DIR__);
spl_autoload_register(function($className) {
$file = $className . '.php';
if (file_exists($file)) {
include $file;
}
$file = "app/Controller/".$className . '.php';
if (file_exists($file)) {
include $file;
}
$file = "app/Libraries/".$className . '.php';
if (file_exists($file)) {
include $file;
}
$file = "app/Model/".$className . '.php';
if (file_exists($file)) {
include $file;
}
});