-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoload.php
35 lines (32 loc) · 879 Bytes
/
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
<?php
/*
* defined function responsible for loading class,
* replacing the old __ autoload.
* ROOT is constant of the path root of the system
*/
spl_autoload_extensions('.php');
spl_autoload_register('loadClasses');
function loadClasses($className)
{
if ( file_exists(APP_PATH.DS.'app/controllers/'.$className.'.php' ) )
{
set_include_path(APP_PATH.DS.'controllers'.DS);
spl_autoload($className);
}
elseif ( file_exists(APP_PATH.DS.'app/models/'.$className.'.php' ) )
{
set_include_path(APP_PATH.DS.'models'.DS);
spl_autoload($className);
}
elseif ( file_exists(APP_PATH.DS.'app/views/'.$className.'.php' ) )
{
set_include_path(APP_PATH.DS.'views'.DS);
spl_autoload($className);
}
else
{
set_include_path(APP_PATH.DS.'lib'.DS);
spl_autoload($className);
}
}
?>