-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
50 lines (38 loc) · 1.18 KB
/
config.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
<?php
$config = require 'core/config/index.php';
// BASE URL
define('BASE_URL', $config['url']['base_url']);
// MVC DIR
define('VIEW_DIR', $config['url']['view_dir']);
define('HELPER_DIR', $config['url']['helper_dir']);
define('LIBRARY_DIR', $config['url']['library_dir']);
// DEFAULT CONTROLLER * FUNCTION
define('DEFAULT_CONTROLLER', $config['url']['default_controller']);
define('DEFAULT_FUNCTION', $config['url']['default_function']);
// load helper
foreach( $config['helper'] as $h ) {
if( file_exists(dirname(__FILE__) . HELPER_DIR . "/{$h}_helper.php") ) { // core/helper/session_helper.php
require_once dirname(__FILE__) . HELPER_DIR . "/{$h}_helper.php";
}else{
echo 'file tidak ada';
}
}
foreach( $config['library'] as $l ) {
if( file_exists(dirname(__FILE__) . LIBRARY_DIR . "/{$l}.php") ) { // core/helper/session_helper.php
require_once dirname(__FILE__) . LIBRARY_DIR . "/{$l}.php";
${$l} = new $l();
}else{
echo 'file tidak ada';
}
}
// KONEKSI DATBASE
$mysql = new mysqli(
$config['db']['host'],
$config['db']['userDb'],
$config['db']['passDb'],
$config['db']['name']
) or die('Can`t connect');
function MySQLInstance() {
global $mysql;
return $mysql;
}