File tree Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ // Check PHP version.
4
+ $ minPhpVersion = '7.4 ' ; // If you update this, don't forget to update `spark`.
5
+ if (version_compare (PHP_VERSION , $ minPhpVersion , '< ' )) {
6
+ $ message = sprintf (
7
+ 'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s ' ,
8
+ $ minPhpVersion ,
9
+ PHP_VERSION
10
+ );
11
+
12
+ exit ($ message );
13
+ }
14
+
3
15
// Path to the front controller (this file)
4
16
define ('FCPATH ' , __DIR__ . DIRECTORY_SEPARATOR );
5
17
Original file line number Diff line number Diff line change @@ -26,6 +26,18 @@ if (strpos(PHP_SAPI, 'cgi') === 0) {
26
26
exit ("The cli tool is not supported when running php-cgi. It needs php-cli to function! \n\n" );
27
27
}
28
28
29
+ // Check PHP version.
30
+ $ minPhpVersion = '7.4 ' ; // If you update this, don't forget to update `public/index.php`.
31
+ if (version_compare (PHP_VERSION , $ minPhpVersion , '< ' )) {
32
+ $ message = sprintf (
33
+ 'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s ' ,
34
+ $ minPhpVersion ,
35
+ PHP_VERSION
36
+ );
37
+
38
+ exit ($ message );
39
+ }
40
+
29
41
// We want errors to be shown when using it from the CLI.
30
42
error_reporting (-1 );
31
43
ini_set ('display_errors ' , '1 ' );
Original file line number Diff line number Diff line change @@ -49,8 +49,6 @@ class CodeIgniter
49
49
*/
50
50
public const CI_VERSION = '4.2.1 ' ;
51
51
52
- private const MIN_PHP_VERSION = '7.4 ' ;
53
-
54
52
/**
55
53
* App startup time.
56
54
*
@@ -158,16 +156,6 @@ class CodeIgniter
158
156
*/
159
157
public function __construct (App $ config )
160
158
{
161
- if (version_compare (PHP_VERSION , self ::MIN_PHP_VERSION , '< ' )) {
162
- // @codeCoverageIgnoreStart
163
- $ message = extension_loaded ('intl ' )
164
- ? lang ('Core.invalidPhpVersion ' , [self ::MIN_PHP_VERSION , PHP_VERSION ])
165
- : sprintf ('Your PHP version must be %s or higher to run CodeIgniter. Current version: %s ' , self ::MIN_PHP_VERSION , PHP_VERSION );
166
-
167
- exit ($ message );
168
- // @codeCoverageIgnoreEnd
169
- }
170
-
171
159
$ this ->startTime = microtime (true );
172
160
$ this ->config = $ config ;
173
161
}
@@ -962,6 +950,7 @@ protected function display404errors(PageNotFoundException $e)
962
950
ob_end_flush (); // @codeCoverageIgnore
963
951
}
964
952
953
+ // Throws new PageNotFoundException and remove exception message on production.
965
954
throw PageNotFoundException::forPageNotFound (
966
955
(ENVIRONMENT !== 'production ' || ! $ this ->isWeb ()) ? $ e ->getMessage () : null
967
956
);
You can’t perform that action at this time.
0 commit comments