forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bootstrap.php
More file actions
175 lines (140 loc) · 5.17 KB
/
Copy path_bootstrap.php
File metadata and controls
175 lines (140 loc) · 5.17 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
//--------------------------------------------------------------------
// CodeIgniter Compatibility Setup
//--------------------------------------------------------------------
// This section gets the environment setup and ready so that your
// tests should have all they need at their fingertips.
//
$startMemory = memory_get_usage();
$startTime = microtime(true);
if (! defined('ENVIRONMENT'))
{
define('ENVIRONMENT', 'testing');
}
switch (ENVIRONMENT)
{
case 'testing':
error_reporting(-1);
ini_set('display_errors', 1);
break;
}
define('CI_DEBUG', 1);
define('SHOW_DEBUG_BACKTRACE', TRUE);
$system_directory = 'system';
$application_directory = 'application';
$writable_directory = 'writable';
$tests_directory = 'tests';
// Ensure the current directory is pointing to the front controller's directory
//chdir(__DIR__);
// Are the system and application paths correct?
if ( ! realpath($system_directory) OR ! is_dir($system_directory))
{
header('HTTP/1.1 503 Service Unavailable.', true, 503);
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.
pathinfo(__FILE__, PATHINFO_BASENAME);
exit(3); // EXIT_CONFIG
}
if ( ! realpath($application_directory) OR ! is_dir($application_directory))
{
header('HTTP/1.1 503 Service Unavailable.', true, 503);
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.
pathinfo(__FILE__, PATHINFO_BASENAME);
exit(3); // EXIT_CONFIG
}
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// Path to the system folder
define('BASEPATH', realpath($system_directory).DIRECTORY_SEPARATOR);
// Path to the front controller (this file)
define('FCPATH', __DIR__.DIRECTORY_SEPARATOR);
// Path to code root folder (just up from public)
define('ROOTPATH', str_replace('public'.DIRECTORY_SEPARATOR, '', FCPATH));
// Path to the writable directory.
define('WRITEPATH', realpath($writable_directory).DIRECTORY_SEPARATOR);
// The path to the "application" folder
define('APPPATH', realpath($application_directory).DIRECTORY_SEPARATOR);
// The path to the "tests" directory
define('TESTPATH', realpath($tests_directory).DIRECTORY_SEPARATOR);
define('SUPPORTPATH', realpath(TESTPATH.'_support/').'/');
/*
* ------------------------------------------------------
* Load any environment-specific settings from .env file
* ------------------------------------------------------
*/
// Load environment settings from .env files
// into $_SERVER and $_ENV
require BASEPATH.'Config/DotEnv.php';
$env = new CodeIgniter\Config\DotEnv(APPPATH);
$env->load();
unset($env);
/*
* ------------------------------------------------------
* Load the framework constants
* ------------------------------------------------------
*/
if (file_exists(APPPATH.'Config/'.ENVIRONMENT.'/Constants.php'))
{
require_once APPPATH.'Config/'.ENVIRONMENT.'/Constants.php';
}
require_once(APPPATH.'Config/Constants.php');
/*
* ------------------------------------------------------
* Setup the autoloader
* ------------------------------------------------------
*/
// The autoloader isn't initialized yet, so load the file manually.
require BASEPATH.'Autoloader/Autoloader.php';
require APPPATH.'Config/Autoload.php';
require APPPATH.'Config/Services.php';
// Use special Services for testing.
require SUPPORTPATH.'Services.php';
// The Autoloader class only handles namespaces
// and "legacy" support.
$loader = CodeIgniter\Services::autoloader();
$loader->initialize(new Config\Autoload());
// The register function will prepend
// the psr4 loader.
$loader->register();
// Add namespace paths to autoload mocks for testing.
$loader->addNamespace('CodeIgniter', SUPPORTPATH);
$loader->addNamespace('Config', SUPPORTPATH.'Config');
/*
* ------------------------------------------------------
* Load the global functions
* ------------------------------------------------------
*/
// Use special global functions for testing.
require_once SUPPORTPATH.'MockCommon.php';
require_once BASEPATH.'Common.php';
/*
* ------------------------------------------------------
* Set custom exception handling
* ------------------------------------------------------
*/
$config = new \Config\App();
Config\Services::exceptions($config, true)
->initialize();
//--------------------------------------------------------------------
// Should we use a Composer autoloader?
//--------------------------------------------------------------------
if ($composer_autoload = $config->composerAutoload)
{
if ($composer_autoload === TRUE)
{
file_exists(APPPATH.'vendor/autoload.php')
? require_once(APPPATH.'vendor/autoload.php')
: log_message('error', '$config->\'composerAutoload\' is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
}
elseif (file_exists($composer_autoload))
{
require_once($composer_autoload);
}
else
{
log_message('error', 'Could not find the specified $config->\'composerAutoload\' path: '.$composer_autoload);
}
}
//--------------------------------------------------------------------
// Load our TestCase
//--------------------------------------------------------------------
require_once __DIR__ .'/CIUnitTestCase.php';