From 0d8cf60830a53fff5eaaa786c07db0c41594ab77 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Wed, 25 Oct 2023 16:04:21 +0200 Subject: [PATCH 1/3] Add Afterburner support to Local Server --- docker/afterburner.ini | 4 ++++ docs/using-afterburner.md | 19 ++++++++++++++++ .../class-docker-compose-generator.php | 22 ++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 docker/afterburner.ini create mode 100644 docs/using-afterburner.md diff --git a/docker/afterburner.ini b/docker/afterburner.ini new file mode 100644 index 00000000..98dca708 --- /dev/null +++ b/docker/afterburner.ini @@ -0,0 +1,4 @@ +extension=afterburner.so + +afterburner.redis_server_info=redis://redis:6379 +afterburner.lru_cache_max_items=1000 diff --git a/docs/using-afterburner.md b/docs/using-afterburner.md new file mode 100644 index 00000000..165b26dc --- /dev/null +++ b/docs/using-afterburner.md @@ -0,0 +1,19 @@ +# Using Afterburner + +If your project uses Afterburner in Altis Cloud, you can enabled it in Altis Local Service by setting the `altis.modules.local-server.afterburner` value to `true`: + +```json +{ + "extra": { + "altis": { + "modules": { + "local-server": { + "afterburner": true + } + } + } + } +} +``` + +Afterburner is only enabled on PHP versions later than 7.4. diff --git a/inc/composer/class-docker-compose-generator.php b/inc/composer/class-docker-compose-generator.php index ba39635c..47923d71 100644 --- a/inc/composer/class-docker-compose-generator.php +++ b/inc/composer/class-docker-compose-generator.php @@ -90,9 +90,9 @@ public function __construct( string $root_dir, string $project_name, string $tld */ protected function get_php_reusable() : array { $version_map = [ - '8.2' => 'humanmade/altis-local-server-php:8.2.3', - '8.1' => 'humanmade/altis-local-server-php:6.0.5', - '8.0' => 'humanmade/altis-local-server-php:5.0.4', + '8.2' => 'humanmade/altis-local-server-php:8.2.9', + '8.1' => 'humanmade/altis-local-server-php:6.0.10', + '8.0' => 'humanmade/altis-local-server-php:5.0.10', '7.4' => 'humanmade/altis-local-server-php:4.2.5', ]; @@ -112,6 +112,21 @@ protected function get_php_reusable() : array { $image = $version_map[ $version ]; + $volumes = [ + $this->get_app_volume(), + "{$this->config_dir}/php.ini:/usr/local/etc/php/conf.d/altis.ini", + 'socket:/var/run/php-fpm', + 'tmp:/tmp', + ]; + + if ( $this->args['xdebug'] !== 'off' ) { + $volumes[] = "{$this->config_dir}/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini"; + } + + if ( $this->get_config()['afterburner'] && $version !== "7.4" ) { + $volumes[] = "{$this->config_dir}/afterburner.ini:/usr/local/etc/php/conf.d/afterburner.ini"; + } + $services = [ 'init' => true, 'depends_on' => [ @@ -867,6 +882,7 @@ protected function get_config() : array { 'cavalcade' => $modules['cloud']['cavalcade'] ?? true, 'elasticsearch' => ( $analytics_enabled || $search_enabled ) ? '7' : false, 'kibana' => ( $analytics_enabled || $search_enabled ), + 'afterburner' => false, 'xray' => $modules['cloud']['xray'] ?? true, 'ignore-paths' => [], 'php' => '8.0', From 0b8419ef15d37af5f213fc0569eddad39b7e43a2 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Wed, 25 Oct 2023 16:55:07 +0200 Subject: [PATCH 2/3] Fix typo --- docs/using-afterburner.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/using-afterburner.md b/docs/using-afterburner.md index 165b26dc..027b3ddd 100644 --- a/docs/using-afterburner.md +++ b/docs/using-afterburner.md @@ -1,6 +1,6 @@ # Using Afterburner -If your project uses Afterburner in Altis Cloud, you can enabled it in Altis Local Service by setting the `altis.modules.local-server.afterburner` value to `true`: +If your project uses Afterburner in Altis Cloud, you can enable it in Altis Local Service by setting the `altis.modules.local-server.afterburner` value to `true`: ```json { From f22a0d0bc8e218af407a6ac10da5b7138900fc16 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Thu, 2 Nov 2023 20:00:30 +0100 Subject: [PATCH 3/3] FIx phpcs --- inc/composer/class-docker-compose-generator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/composer/class-docker-compose-generator.php b/inc/composer/class-docker-compose-generator.php index 47923d71..14d0fe42 100644 --- a/inc/composer/class-docker-compose-generator.php +++ b/inc/composer/class-docker-compose-generator.php @@ -123,7 +123,7 @@ protected function get_php_reusable() : array { $volumes[] = "{$this->config_dir}/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini"; } - if ( $this->get_config()['afterburner'] && $version !== "7.4" ) { + if ( $this->get_config()['afterburner'] && $version !== '7.4' ) { $volumes[] = "{$this->config_dir}/afterburner.ini:/usr/local/etc/php/conf.d/afterburner.ini"; }