diff --git a/deploy.php.sample_2_1 b/deploy.php.sample_2_1 index 0aa6f37..d94a844 100644 --- a/deploy.php.sample_2_1 +++ b/deploy.php.sample_2_1 @@ -15,6 +15,8 @@ set('magento_dir', 'magento'); set('repository', ''); // Space separated list of languages for static-content:deploy set('languages', 'en_US'); +// Enable all caches after deployment +set('cache_enabled_caches', 'all'); // OPcache configuration task('cache:clear:opcache', 'sudo systemctl reload php-fpm'); diff --git a/deploy.php.sample_2_2 b/deploy.php.sample_2_2 index 6dc8d82..9d19e04 100644 --- a/deploy.php.sample_2_2 +++ b/deploy.php.sample_2_2 @@ -15,6 +15,8 @@ set('magento_dir', 'magento'); set('repository', ''); // Space separated list of languages for static-content:deploy set('languages', 'en_US'); +// Enable all caches after deployment +set('cache_enabled_caches', 'all'); // OPcache configuration task('cache:clear:opcache', 'sudo systemctl reload php-fpm'); diff --git a/deploy.php.sample_2_2_5 b/deploy.php.sample_2_2_5 index a3bcd1b..50b7277 100644 --- a/deploy.php.sample_2_2_5 +++ b/deploy.php.sample_2_2_5 @@ -15,6 +15,8 @@ set('magento_dir', 'magento'); set('repository', ''); // Space separated list of languages for static-content:deploy set('languages', 'en_US'); +// Enable all caches after deployment +set('cache_enabled_caches', 'all'); // OPcache configuration task('cache:clear:opcache', 'sudo systemctl reload php-fpm'); diff --git a/recipe/magento_2_1/cache.php b/recipe/magento_2_1/cache.php index f5ce13c..5c78696 100644 --- a/recipe/magento_2_1/cache.php +++ b/recipe/magento_2_1/cache.php @@ -21,3 +21,55 @@ invoke('cache:clear:magento') : writeln('Skipped -> maintenance is not set'); }); + +/* + * By default, cache enabling is disabled. + */ +set('cache_enabled_caches', ''); + +/* + * To enable all caches after deployment, configure the following: + * +set('cache_enabled_caches', 'all'); + */ + +/* + * One can provide specific caches as well. + * +set('cache_enabled_caches', + [ + 'config', + 'layout', + 'block_html', + 'collections', + 'reflection', + 'db_ddl', + 'eav', + 'customer_notification', + 'full_page', + 'config_integration', + 'config_integration_api', + 'translate', + 'config_webservice', + 'compiled_config', + ] +); + */ + +task('cache:enable', function () { + $enabledCaches = get('cache_enabled_caches'); + + if (empty($enabledCaches)) { + return; + } + + $command = '{{bin/php}} {{release_path}}/{{magento_bin}} cache:enable'; + + if ($enabledCaches === 'all') { + run($command); + } + + if (is_array($enabledCaches)) { + run($command . ' ' . implode(' ', $enabledCaches)); + } +}); diff --git a/recipe/magento_2_2.php b/recipe/magento_2_2.php index 1069242..cf08b38 100644 --- a/recipe/magento_2_2.php +++ b/recipe/magento_2_2.php @@ -55,6 +55,7 @@ 'deploy:symlink', 'maintenance:unset', 'cache:clear', + 'cache:enable', 'deploy:unlock', 'cleanup', 'success', @@ -84,6 +85,7 @@ 'deploy:symlink', 'maintenance:unset', 'cache:clear', + 'cache:enable', 'deploy:unlock', 'cleanup', 'success',