-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
159 lines (135 loc) · 4.12 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use CodeIgniter\Config\DotEnv;
use Config\Autoload;
use Config\Modules;
use Config\Paths;
use Config\Services;
/*
* ---------------------------------------------------------------
* SETUP OUR PATH CONSTANTS
* ---------------------------------------------------------------
*
* The path constants provide convenient access to the folders
* throughout the application. We have to setup them up here
* so they are available in the config files that are loaded.
*/
// The path to the application directory.
if (! defined('APPPATH'))
{
/**
* @var Paths $paths
*/
define('APPPATH', realpath(rtrim($paths->appDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
}
// The path to the project root directory. Just above APPPATH.
if (! defined('ROOTPATH'))
{
define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR);
}
// The path to the system directory.
if (! defined('SYSTEMPATH'))
{
/**
* @var Paths $paths
*/
define('SYSTEMPATH', realpath(rtrim($paths->systemDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
}
// The path to the writable directory.
if (! defined('WRITEPATH'))
{
/**
* @var Paths $paths
*/
define('WRITEPATH', realpath(rtrim($paths->writableDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
}
// The path to the tests directory
if (! defined('TESTPATH'))
{
/**
* @var Paths $paths
*/
define('TESTPATH', realpath(rtrim($paths->testsDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
}
/*
* ---------------------------------------------------------------
* GRAB OUR CONSTANTS & COMMON
* ---------------------------------------------------------------
*/
if (! defined('APP_NAMESPACE'))
{
require_once APPPATH . 'Config/Constants.php';
}
// Require app/Common.php file if exists.
if (is_file(APPPATH . 'Common.php'))
{
require_once APPPATH . 'Common.php';
}
// Require system/Common.php
require_once SYSTEMPATH . 'Common.php';
/*
* ---------------------------------------------------------------
* LOAD OUR AUTOLOADER
* ---------------------------------------------------------------
*
* The autoloader allows all of the pieces to work together in the
* framework. We have to load it here, though, so that the config
* files can use the path constants.
*/
if (! class_exists('Config\Autoload', false))
{
require_once SYSTEMPATH . 'Config/AutoloadConfig.php';
require_once APPPATH . 'Config/Autoload.php';
require_once SYSTEMPATH . 'Modules/Modules.php';
require_once APPPATH . 'Config/Modules.php';
}
require_once SYSTEMPATH . 'Autoloader/Autoloader.php';
require_once SYSTEMPATH . 'Config/BaseService.php';
require_once SYSTEMPATH . 'Config/Services.php';
require_once APPPATH . 'Config/Services.php';
// Use Config\Services as CodeIgniter\Services
if (! class_exists('CodeIgniter\Services', false))
{
class_alias('Config\Services', 'CodeIgniter\Services');
}
// Initialize and register the loader with the SPL autoloader stack.
Services::autoloader()->initialize(new Autoload(), new Modules())->register();
// Now load Composer's if it's available
if (is_file(COMPOSER_PATH))
{
/*
* The path to the vendor directory.
*
* We do not want to enforce this, so set the constant if Composer was used.
*/
if (! defined('VENDORPATH'))
{
define('VENDORPATH', realpath(ROOTPATH . 'vendor') . DIRECTORY_SEPARATOR);
}
require_once COMPOSER_PATH;
}
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
$env = new DotEnv(ROOTPATH);
$env->load();
// Always load the URL helper, it should be used in most of apps.
helper('url');
/*
* ---------------------------------------------------------------
* GRAB OUR CODEIGNITER INSTANCE
* ---------------------------------------------------------------
*
* The CodeIgniter class contains the core functionality to make
* the application run, and does all of the dirty work to get
* the pieces all working together.
*/
$app = Services::codeigniter();
$app->initialize();
return $app;