-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
67 lines (58 loc) · 1.49 KB
/
autoload.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace config;
/**
* autoload files
*
* 1. fonctions services / ft_
* 2. models class/entity
* 3. repositories
* 4. controllers
* 5. views
*/
function autoloader($class)
{
$namespaces = [
'services',
'repositories',
'controllers',
'views',
'views/layouts',
'views/layouts/templates',
'models',
''];
foreach ($namespaces as $prefix) {
if (file_exists("$prefix\\$class.php")) {
$file = "$prefix\\$class.php";
var_dump($file);
die;
// require_once $file;
}
}
}
spl_autoload_register(function ($class) {
if (file_exists("models\\$class.php")) {
require_once "models\\$class.php";
}
if (file_exists("$class.php")) {
require_once "$class.php";
}
if (file_exists("services\\$class.php")) {
require_once "services\\$class.php";
}
if (file_exists("repositories\\$class.php")) {
require_once "repositories\\$class.php";
}
if (file_exists("controllers\\$class.php")) {
require_once "controllers\\$class.php";
}
if (file_exists("views\\$class.php")) {
require_once "views\\$class.php";
}
if (file_exists("views\layouts\\$class.php")) {
require_once "views\layouts\\$class.php";
}
if (file_exists("views\layouts\templates\\$class.php")) {
require_once "views\layouts\templates\\$class.php";
}
});
//spl_autoload_register('config\autoloader');