-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
bootstrap.php
101 lines (82 loc) · 1.95 KB
/
bootstrap.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
use Phalcon\Config\Config;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Url;
use Phalcon\Mvc\View;
$container = new FactoryDefault();
/**
* Load environment
*/
$root = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR;
loadIni();
loadAutoloader($root);
loadFolders();
loadDefined();
/**
* Config
*/
$configFile = [
'application' => [
'baseUri' => '/',
'staticUri' => '/',
'timezone' => 'UTC',
'controllersDir' => $root . 'tests/_data/fixtures/controllers/',
'modelsDir' => $root . 'tests/_data/fixtures/models/',
'modulesDir' => $root . 'tests/_data/fixtures/modules/',
'viewsDir' => $root . 'tests/_data/fixtures/views/',
'resultsetsDir' => $root . 'tests/_data/fixtures/resultsets/',
'tasksDir' => $root . 'tests/_data/fixtures/tasks/',
]
];
$config = new Config($configFile);
$container->setShared('config', $config);
/**
* View
*/
$container->setShared(
'view',
function () use ($configFile) {
$view = new View();
$view->setViewsDir(
$configFile['application']['viewsDir']
);
return $view;
}
);
/**
* The URL component is used to generate all kind of urls in the
* application
*/
$container->setShared(
'url',
function () use ($configFile) {
$url = new Url();
$url->setStaticBaseUri(
$configFile['application']['staticUri']
);
$url->setBaseUri(
$configFile['application']['baseUri']
);
return $url;
}
);
/**
* Router
*/
$container->setShared(
'router',
function () {
return new Router(false);
}
);
/**
* Dispatcher
*/
$container->set('dispatcher', Dispatcher::class);
$application = new Application();
$application->setDI($container);
FactoryDefault::setDefault($container);
return $application;