Skip to content

Commit 18a7ae9

Browse files
committed
Check for minimum PHP version. Fixes #1307
1 parent f5fd071 commit 18a7ae9

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

public/index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
// Valid PHP Version?
4+
$minPHPVersion = '7.1';
5+
if (phpversion() < $minPHPVersion)
6+
{
7+
die("You PHP version must be {$minPHPVersion} or higher to run CodeIgniter. Current version: ". phpversion());
8+
}
9+
unset($minPHPVersion);
10+
311
// Path to the front controller (this file)
412
define('FCPATH', __DIR__.DIRECTORY_SEPARATOR);
513

system/Commands/Server/Serve.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@
4141

4242
/**
4343
* Launch the PHP development server
44-
*
44+
*
4545
* Not testable, as it throws phpunit for a loop :-/
4646
* @codeCoverageIgnore
4747
*/
4848
class Serve extends BaseCommand
4949
{
50+
protected $minPHPVersion = '7.1';
5051

5152
protected $group = 'CodeIgniter';
5253
protected $name = 'serve';
@@ -61,6 +62,12 @@ class Serve extends BaseCommand
6162

6263
public function run(array $params)
6364
{
65+
// Valid PHP Version?
66+
if (phpversion() < $this->minPHPVersion)
67+
{
68+
die("You PHP version must be {$this->minPHPVersion} or higher to run CodeIgniter. Current version: ". phpversion());
69+
}
70+
6471
// Collect any user-supplied options and apply them
6572
$php = CLI::getOption('php') ?? PHP_BINARY;
6673
$host = CLI::getOption('host') ?? 'localhost';

0 commit comments

Comments
 (0)