forked from k-samuel/dvelum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.php
61 lines (53 loc) · 1.52 KB
/
console.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
<?php
/*
* DVelum console application
* Return codes
* 0 - Good
* 1 - Empty URI
* 2 - Wrong URI
* 3 - Application Error
*/
if (isset($_SERVER['argc']) && $_SERVER['argc']!==2 ){
exit(1);
}
$_SERVER['DOCUMENT_ROOT'] = __DIR__.'/www';
chdir(__DIR__.'/www');
define('DVELUM', true);
define('DVELUM_CONSOLE', true);
define('DVELUM_ROOT' , __DIR__.'/www');
/*
* Connecting main configuration file
*/
$config = include './system/config/main.php';
/*
* Including Autoloader class
*/
require $config['docroot'].'/system/library/Autoloader.php';
/*
* Setting autoloader config
*/
$autoloaderCfg = $config['autoloader'];
$autoloaderCfg['debug'] = $config['development'];
if($autoloaderCfg['useMap'] && $autoloaderCfg['usePackages'] && $autoloaderCfg['mapPackaged'])
$autoloaderCfg['map'] = require $autoloaderCfg['mapPackaged'];
elseif($autoloaderCfg['useMap'] && !$autoloaderCfg['usePackages'] && $autoloaderCfg['map'])
$autoloaderCfg['map'] = require $autoloaderCfg['map'];
else
$autoloaderCfg['map'] = false;
$autoloader = new Autoloader($autoloaderCfg);
/**
* Convert the data of main_config file
* in to the general form of configuration
* and save a reference for it (for convenience)
* @var Config_Simple $appConfig
*/
$appConfig = Config::factory(Config::Simple, 'main');
$appConfig->setData($config);
Registry::set('main', $appConfig , 'config');
/*
* Starting the application
*/
$app = new Application($appConfig);
$app->setAutoloader($autoloader);
Request::getInstance()->setUri($_SERVER['argv'][1]);
$app->run();