drenso/symfony-deployer-bundle
Install the Bundle Add the package via Composer:
composer require drenso/symfony-deployer-bundle
Enable the bundle in config/bundles.php:
return [
// ...
Drenso\DeployerBundle\DrensoDeployerBundle::class => ['all' => true],
];
Generate a Script Create a new deployer script:
bin/console drenso:deployer:generate
This generates a YAML file at config/deployer/scripts.yml with a default always script.
First Use Case Define a simple pre-deployment script (e.g., clearing cache):
# config/deployer/scripts.yml
pre:
always:
- name: "Clear Symfony cache"
command: "php bin/console cache:clear"
Run it during deployment:
bin/console drenso:deployer:pre
Structured Deployment Hooks
Organize scripts into pre and post hooks with always (runs every deployment) or once (runs only once, then skips):
pre:
always:
- name: "Backup database"
command: "mysqldump -u user -p db_name > backup.sql"
once:
- name: "Run migrations"
command: "php bin/console doctrine:migrations:migrate"
Conditional Execution Skip scripts based on conditions (e.g., environment, file existence):
pre:
always:
- name: "Optimize assets"
command: "npm run build"
skipIf: "!app.env == 'prod'"
Integration with Deployment Tools Use the bundle alongside tools like Deployer or Ansible by embedding its commands in your workflow:
# In your Deployer recipe
task('deploy:pre', function () {
run('cd {{release_path}} && ./bin/console drenso:deployer:pre');
});
skipIf to avoid running scripts in non-production environments.pre:
always:
- name: "Log environment"
command: "php bin/console about | tee -a deploy.log"
config/deployer/scripts/ and reference them via YAML includes.YAML Syntax Errors
bin/console debug:config drenso_deployer
once Scripts Not Skipping
once script runs unexpectedly, check if the skipIf condition is misconfigured or if the script was manually reset (e.g., via drenso:deployer:reset).Command Execution Failures
ignoreErrors: false to enforce failure handling:
pre:
always:
- name: "Critical step"
command: "php bin/console cache:warmup"
ignoreErrors: false
bin/console drenso:deployer:pre --dry-run
bin/console drenso:deployer:pre -vvv
Custom Command Types
Extend the bundle by adding new command types (e.g., daily, weekly) via a custom service:
# config/services.yaml
Drenso\DeployerBundle\Command\ScriptCommandInterface: '@custom.deployer.command'
Dynamic Scripts
Load scripts dynamically from a database or API by overriding the ScriptLoader service.
Parallel Execution
Use Symfony’s Parallel component to run independent scripts concurrently (requires custom implementation).
config/deployer/scripts.yml is writable by the web server.bin/console cache:clear
How can I help you explore Laravel packages today?