mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 16:54:08 +01:00
* Fix symfony cache:clear running twice on deployment Any standard symfony app is running cache:clear on composer install ever since. I.e. in composer.json ``` "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, ``` This prevents cache clearing being run twice for no reason. * regenerate doc
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
namespace Deployer;
|
|
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
add('recipes', ['symfony']);
|
|
|
|
set('symfony_version', function () {
|
|
$result = run('{{bin/console}} --version');
|
|
preg_match_all('/(\d+\.?)+/', $result, $matches);
|
|
return $matches[0][0] ?? 5.0;
|
|
});
|
|
|
|
set('shared_dirs', [
|
|
'var/log',
|
|
'var/sessions'
|
|
]);
|
|
|
|
set('shared_files', [
|
|
'.env.local'
|
|
]);
|
|
|
|
set('writable_dirs', [
|
|
'var'
|
|
]);
|
|
|
|
set('migrations_config', '');
|
|
|
|
set('bin/console', '{{bin/php}} {{release_or_current_path}}/bin/console');
|
|
|
|
set('console_options', function () {
|
|
return '--no-interaction';
|
|
});
|
|
|
|
desc('Migrate database');
|
|
task('database:migrate', function () {
|
|
$options = '--allow-no-migration';
|
|
if (get('migrations_config') !== '') {
|
|
$options = "$options --configuration={{release_or_current_path}}/{{migrations_config}}";
|
|
}
|
|
|
|
run("cd {{release_or_current_path}} && {{bin/console}} doctrine:migrations:migrate $options {{console_options}}");
|
|
});
|
|
|
|
desc('Clear cache');
|
|
task('deploy:cache:clear', function () {
|
|
// composer install scripts usually clear and warmup symfony cache
|
|
// so we only need to do it if composer install was run with --no-scripts
|
|
if (false !== strpos(get('composer_options', ''), '--no-scripts')) {
|
|
run('{{bin/console}} cache:clear {{console_options}}');
|
|
}
|
|
});
|
|
|
|
desc('Deploy project');
|
|
task('deploy', [
|
|
'deploy:prepare',
|
|
'deploy:vendors',
|
|
'deploy:cache:clear',
|
|
'deploy:publish',
|
|
]);
|