-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit.php
49 lines (39 loc) · 1.13 KB
/
init.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
// define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', __DIR__ . '/application');
// define application environment
if (!defined('APPLICATION_ENV')) {
$env = getenv('APPLICATION_ENV');
define('APPLICATION_ENV', $env !== false ? $env :
file_get_contents(APPLICATION_PATH . '/configs/application.id'));
}
// set include path
set_include_path(realpath(APPLICATION_PATH . '/../library')
. PATH_SEPARATOR . get_include_path());
// include zend application
require_once 'Zend/Application.php';
class Application
{
static public $env;
static function bootstrap($resource = null)
{
$application = new Zend_Application(self::_getEnv(), self::_getConfig());
return $application->getBootstrap()->bootstrap($resource);
}
static function run()
{
self::bootstrap()->run();
}
private static function _getEnv()
{
return self::$env ?: APPLICATION_ENV;
}
private static function _getConfig()
{
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", self::_getEnv(), true);
$config = $config->toArray();
return $config;
}
}