File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php
22
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+
315// Path to the front controller (this file)
416define ('FCPATH ' , __DIR__ . DIRECTORY_SEPARATOR );
517
Original file line number Diff line number Diff line change @@ -26,6 +26,18 @@ if (strpos(PHP_SAPI, 'cgi') === 0) {
2626 exit ("The cli tool is not supported when running php-cgi. It needs php-cli to function! \n\n" );
2727}
2828
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+
2941// We want errors to be shown when using it from the CLI.
3042error_reporting (-1 );
3143ini_set ('display_errors ' , '1 ' );
Original file line number Diff line number Diff line change @@ -49,8 +49,6 @@ class CodeIgniter
4949 */
5050 public const CI_VERSION = '4.2.1 ' ;
5151
52- private const MIN_PHP_VERSION = '7.4 ' ;
53-
5452 /**
5553 * App startup time.
5654 *
@@ -158,16 +156,6 @@ class CodeIgniter
158156 */
159157 public function __construct (App $ config )
160158 {
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-
171159 $ this ->startTime = microtime (true );
172160 $ this ->config = $ config ;
173161 }
@@ -962,6 +950,7 @@ protected function display404errors(PageNotFoundException $e)
962950 ob_end_flush (); // @codeCoverageIgnore
963951 }
964952
953+ // Throws new PageNotFoundException and remove exception message on production.
965954 throw PageNotFoundException::forPageNotFound (
966955 (ENVIRONMENT !== 'production ' || ! $ this ->isWeb ()) ? $ e ->getMessage () : null
967956 );
You can’t perform that action at this time.
0 commit comments