Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
*/
class PHP extends EE_Site_Command {

/**
* Default PHP version for new sites. Single source of truth: this is also
* the version the `latest` image tag resolves to and the 8.x fallback for
* unsupported requests. Change this one constant to move the default.
*/
const DEFAULT_PHP_VERSION = '8.4';

/**
* All PHP versions EasyEngine ships images for. Keep in sync with the
* `--php` options list in the create() docblock.
*/
const SUPPORTED_PHP_VERSIONS = [ '5.6', '7.0', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', 'latest' ];

/**
* @var string $cache_type Type of caching being used.
*/
Expand Down Expand Up @@ -83,7 +96,6 @@ public function __construct() {
* [--php=<php-version>]
* : PHP version for site. Currently only supports PHP 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and latest.
* ---
* default: 8.4
* options:
* - 5.6
* - 7.0
Expand All @@ -95,7 +107,7 @@ public function __construct() {
* - 8.2
* - 8.3
* - 8.4
* - 8.5
* - 8.5
* - latest
* ---
*
Expand Down Expand Up @@ -198,7 +210,7 @@ public function create( $args, $assoc_args ) {
$this->site_data['site_fs_path'] = WEBROOT . $this->site_data['site_url'];
$this->cache_type = \EE\Utils\get_flag_value( $assoc_args, 'cache' );
$this->site_data['site_ssl_wildcard'] = \EE\Utils\get_flag_value( $assoc_args, 'wildcard' );
$this->site_data['php_version'] = \EE\Utils\get_flag_value( $assoc_args, 'php' );
$this->site_data['php_version'] = \EE\Utils\get_flag_value( $assoc_args, 'php', self::DEFAULT_PHP_VERSION );
$this->site_data['app_sub_type'] = 'php';

$this->site_data['site_container_fs_path'] = get_public_dir( $assoc_args );
Expand Down Expand Up @@ -230,8 +242,8 @@ public function create( $args, $assoc_args ) {
}
$this->site_data['alias_domains'] = substr( $this->site_data['alias_domains'], 0, - 1 );

$supported_php_versions = [ 5.6, 7.0, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 'latest' ];
if ( ! in_array( $this->site_data['php_version'], $supported_php_versions ) ) {
$supported_php_versions = self::SUPPORTED_PHP_VERSIONS;
if ( ! in_array( $this->site_data['php_version'], $supported_php_versions, true ) ) {
$old_version = $this->site_data['php_version'];
$floor = (int) floor( $this->site_data['php_version'] );
if ( 5 === $floor ) {
Expand All @@ -240,7 +252,7 @@ public function create( $args, $assoc_args ) {
$this->site_data['php_version'] = 7.4;
$old_version .= ' yet';
} elseif ( 8 === $floor ) {
$this->site_data['php_version'] = 8.4;
$this->site_data['php_version'] = self::DEFAULT_PHP_VERSION;
$old_version .= ' yet';
} else {
EE::error( 'Unsupported PHP version: ' . $this->site_data['php_version'] );
Expand Down
2 changes: 1 addition & 1 deletion src/Site_PHP_Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function generate_docker_compose_yml( array $filters = [], $volumes ) {
$db['networks'] = $network_default;
}
// PHP configuration.
$php_image_key = ( 'latest' === $filters['php_version'] ? 'easyengine/php8.4' : 'easyengine/php' . $filters['php_version'] );
$php_image_key = ( 'latest' === $filters['php_version'] ? 'easyengine/php' . PHP::DEFAULT_PHP_VERSION : 'easyengine/php' . $filters['php_version'] );

$php['service_name'] = [ 'name' => 'php' ];
$php['image'] = [ 'name' => $php_image_key . ':' . $img_versions[ $php_image_key ] ];
Expand Down
Loading