-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
46 lines (39 loc) · 1.41 KB
/
init.php
File metadata and controls
46 lines (39 loc) · 1.41 KB
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
<?php
/**
* NunezEngine
* Micro-framework for rapid web application development.
*
* @author Raymond Nunez <rpnunez@gmail.com>
* @version v0.1
*/
define('DS', DIRECTORY_SEPARATOR);
define('BASE_PATH', dirName(__FILE__));
define('APP_PATH', BASE_PATH . DS . 'app');
define('SYSTEM_PATH', BASE_PATH . DS . 'system');
define('ENV', '0'); // Environment - 0 = Dev, 1 = Production
spl_autoload_register(function($className) {
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
echo 'Attempting to require_once: '. $className .' ('. $fileName .').<br />';
require_once $fileName;
});
// Include configuration files
$Config = new stdClass();
$files = array('engine', 'db');
foreach ($files as $file) {
$filePath = APP_PATH . DS . 'config' . DS . $file .'.php';
if (!file_exists($filePath)) {
throw new Exception('Require config file missing: '. $file .'.php, file path: '. $filePath);
} else {
$Config->$file = require_once $filePath;
}
}
// Include commonly used functions
include_once(SYSTEM_PATH . DS . '/common.php');