Skip to content

Commit dcad5c4

Browse files
committed
New boot files for environments.
1 parent 3229fb7 commit dcad5c4

4 files changed

Lines changed: 136 additions & 31 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| ERROR DISPLAY
6+
|--------------------------------------------------------------------------
7+
*/
8+
9+
// In development, we want to show as many errors as possible to help
10+
// make sure they don't make it to production. And save us hours of
11+
// painful debugging.
12+
error_reporting(-1);
13+
ini_set('display_errors', 1);
14+
15+
/*
16+
|--------------------------------------------------------------------------
17+
| DEBUG BACKTRACES
18+
|--------------------------------------------------------------------------
19+
| If true, this constant will tell the error screens to display debug
20+
| backtraces along with the other error information. If you would
21+
| prefer to not see this, set this value to false.
22+
*/
23+
define('SHOW_DEBUG_BACKTRACE', true);
24+
25+
/*
26+
|--------------------------------------------------------------------------
27+
| KINT
28+
|--------------------------------------------------------------------------
29+
| If true, will enable the Kint PHP Debugging tool and make it available
30+
| globally throughout your application to use while making sure things
31+
| work the way you intend them to.
32+
*/
33+
$useKint = true;
34+
35+
/*
36+
|--------------------------------------------------------------------------
37+
| DEBUG MODE
38+
|--------------------------------------------------------------------------
39+
| Debug mode is an experimental flag that can allow changes throughout
40+
| the system. It's not widely used currently, and may not survive
41+
| release of the framework.
42+
*/
43+
44+
define('CI_DEBUG', 1);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| ERROR DISPLAY
6+
|--------------------------------------------------------------------------
7+
*/
8+
9+
// Don't show ANY in production environments. Instead, let the system catch
10+
// it and display a generic error message.
11+
ini_set('display_errors', 0);
12+
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
13+
14+
/*
15+
|--------------------------------------------------------------------------
16+
| DEBUG MODE
17+
|--------------------------------------------------------------------------
18+
| Debug mode is an experimental flag that can allow changes throughout
19+
| the system. It's not widely used currently, and may not survive
20+
| release of the framework.
21+
*/
22+
23+
define('CI_DEBUG', 0);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| ERROR DISPLAY
6+
|--------------------------------------------------------------------------
7+
*/
8+
9+
// In development, we want to show as many errors as possible to help
10+
// make sure they don't make it to production. And save us hours of
11+
// painful debugging.
12+
error_reporting(-1);
13+
ini_set('display_errors', 1);
14+
15+
/*
16+
|--------------------------------------------------------------------------
17+
| DEBUG BACKTRACES
18+
|--------------------------------------------------------------------------
19+
| If true, this constant will tell the error screens to display debug
20+
| backtraces along with the other error information. If you would
21+
| prefer to not see this, set this value to false.
22+
*/
23+
define('SHOW_DEBUG_BACKTRACE', true);
24+
25+
/*
26+
|--------------------------------------------------------------------------
27+
| KINT
28+
|--------------------------------------------------------------------------
29+
| If true, will enable the Kint PHP Debugging tool and make it available
30+
| globally throughout your application to use while making sure things
31+
| work the way you intend them to.
32+
*/
33+
$useKint = true;
34+
35+
/*
36+
|--------------------------------------------------------------------------
37+
| DEBUG MODE
38+
|--------------------------------------------------------------------------
39+
| Debug mode is an experimental flag that can allow changes throughout
40+
| the system. It's not widely used currently, and may not survive
41+
| release of the framework.
42+
*/
43+
44+
define('CI_DEBUG', 1);

public/index.php

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,6 @@
3434
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
3535
}
3636

37-
/*
38-
*---------------------------------------------------------------
39-
* ERROR REPORTING
40-
*---------------------------------------------------------------
41-
*
42-
* Different environments will require different levels of error reporting.
43-
* By default development will show errors but testing and live will hide them.
44-
*/
45-
switch (ENVIRONMENT)
46-
{
47-
case 'development':
48-
case 'testing':
49-
error_reporting(-1);
50-
ini_set('display_errors', 1);
51-
define('CI_DEBUG', 1);
52-
define('SHOW_DEBUG_BACKTRACE', TRUE);
53-
$useKint = true;
54-
break;
55-
56-
case 'production':
57-
ini_set('display_errors', 0);
58-
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
59-
define('CI_DEBUG', 0);
60-
break;
61-
62-
default:
63-
header('HTTP/1.1 503 Service Unavailable.', true, 503);
64-
echo 'The application environment is not set correctly.';
65-
exit(1); // EXIT_ERROR
66-
}
67-
6837
/*
6938
*---------------------------------------------------------------
7039
* SYSTEM FOLDER NAME
@@ -170,6 +139,31 @@
170139
// The path to the "tests" directory
171140
define('TESTPATH', realpath($tests_directory).DIRECTORY_SEPARATOR);
172141

142+
/*
143+
*---------------------------------------------------------------
144+
* BOOT THE ENVIRONMENT
145+
*---------------------------------------------------------------
146+
*
147+
* The boot files allow you completely customize the working
148+
* conditions in this environment, including turning error
149+
* reporting on or off, loading up extra debugging tools,
150+
* and more.
151+
*
152+
* A file matching the name of the current environment must
153+
* be found under application/Config/Boot or the system
154+
* will stop execution.
155+
*/
156+
if (file_exists(APPPATH.'Config/Boot/'.ENVIRONMENT.'.php'))
157+
{
158+
require APPPATH.'Config/Boot/'.ENVIRONMENT.'.php';
159+
}
160+
else
161+
{
162+
header('HTTP/1.1 503 Service Unavailable.', true, 503);
163+
echo 'The application environment is not set correctly.';
164+
exit(1); // EXIT_ERROR
165+
}
166+
173167
/*
174168
* ------------------------------------------------------
175169
* Load the Kint Debugger

0 commit comments

Comments
 (0)