Skip to content

Commit

Permalink
Update version checking in terminus.php
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Dec 18, 2024
1 parent e231b62 commit 411ce53
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 7 additions & 2 deletions bin/terminus.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
// Unset memory limit
ini_set('memory_limit', -1);

if (version_compare(PHP_VERSION, '8.2.0', '<') === true) {
// Look up minimum PHP version from composer.json.
$composer_json_contents = file_get_contents(dirname(__DIR__) . '/composer.json');
$composer_json_data = json_decode($composer_json_contents, true);
$min_php_version = $composer_json_data['config']['platform']['php'];

if (version_compare(PHP_VERSION, $min_php_version, '<') === true) {
fwrite(STDERR, "\n");
fwrite(STDERR, 'Sorry, your PHP version (' . PHP_VERSION . ') is no longer supported.' . "\n");
fwrite(STDERR, 'Upgrade to PHP 8.2 or newer to use Terminus 4. For PHP versions prior to 8.2, downgrade to Terminus 3.x.' . "\n\n");
fwrite(STDERR, 'Upgrade to PHP ' . $min_php_version . ' or newer to use Terminus 4. For prior PHP versions, downgrade to Terminus 3.x.' . "\n\n");
fwrite(STDERR, 'For more information, see https://pantheon.io/docs/terminus/updates#php-version-compatibility-matrix' . "\n\n");
exit(1);
}
Expand Down
20 changes: 12 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 411ce53

Please sign in to comment.