move check to CodeIgniter class

This commit is contained in:
Abdul Malik Ikhsan 2021-03-15 02:25:47 +07:00
parent 61a886726f
commit bd65ddf5e8
No known key found for this signature in database
GPG Key ID: 80035E72114C7548
4 changed files with 16 additions and 38 deletions

View File

@ -25,7 +25,6 @@ $paths = new Config\Paths();
// Location of the framework bootstrap file.
$bootstrap = rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
$app = require realpath($bootstrap) ?: $bootstrap;
CodeIgniter\PhpRequirement::validatePHPVersion();
/*
*---------------------------------------------------------------

1
spark
View File

@ -43,7 +43,6 @@ chdir(FCPATH);
$bootstrap = rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
$app = require realpath($bootstrap) ?: $bootstrap;
CodeIgniter\PhpRequirement::validatePHPVersion();
// Grab our Console
$console = new CodeIgniter\CLI\Console($app);

View File

@ -46,6 +46,11 @@ class CodeIgniter
*/
const CI_VERSION = '4.1.1';
/**
* @var string
*/
private const MIN_PHP_VERSION = '7.3';
/**
* App startup time.
*
@ -147,6 +152,17 @@ class CodeIgniter
*/
public function __construct(App $config)
{
if (version_compare(PHP_VERSION, self::MIN_PHP_VERSION, '<'))
{
die(
sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
self::MIN_PHP_VERSION,
PHP_VERSION
)
);
}
$this->startTime = microtime(true);
$this->config = $config;
}

View File

@ -1,36 +0,0 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter;
final class PhpRequirement
{
/**
* @var string
*/
private const MIN_PHP_VERSION = '7.3';
public static function validatePHPVersion(): void
{
if (! version_compare(PHP_VERSION, self::MIN_PHP_VERSION, '<'))
{
return;
}
die(
sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
self::MIN_PHP_VERSION,
PHP_VERSION
)
);
}
}