How to Deploy a Symfony Application
require 'recipe/symfony.php';
Deployer is a free and open source deployment tool written in PHP. It helps you to deploy your Symfony application to a server. It is very easy to use and has a lot of features.
Three main features of Deployer are:
- Provisioning - provision your server for you.
- Zero downtime deployment - deploy your application without a downtime.
- Rollbacks - rollback your application to a previous version, if something goes wrong.
Additionally, Deployer has a lot of other features, like:
- Easy to use - Deployer is very easy to use. It has a simple and intuitive syntax.
- Fast - Deployer is very fast. It uses parallel connections to deploy your application.
- Secure - Deployer uses SSH to connect to your server.
- Supports all major PHP frameworks - Deployer supports all major PHP frameworks.
You can read more about Deployer in Getting Started.
The deploy task of Symfony consists of:
- deploy:prepare – Prepares a new release
- deploy:info – Displays info about deployment
- deploy:setup – Prepares host for deploy
- deploy:lock – Locks deploy
- deploy:release – Prepares release
- deploy:update_code – Updates code
- deploy:env – Configure .env file
- deploy:shared – Creates symlinks for shared files and dirs
- deploy:writable – Makes writable dirs
- deploy:vendors – Installs vendors
- deploy:cache:clear – Clears cache
- deploy:publish – Publishes the release
- deploy:symlink – Creates symlink to release
- deploy:unlock – Unlocks deploy
- deploy:cleanup – Cleanup old releases
- deploy:success – Deploys your project
The symfony recipe is based on the common recipe.
Configuration
symfony_version
Default value
$result = run('{{bin/console}} --version');
preg_match_all('/(\d+\.?)+/', $result, $matches);
return $matches[0][0] ?? 5.0;
shared_dirs
Overrides shared_dirs from recipe/deploy/shared.php
.
Default value
[
'var/log',
]
shared_files
Overrides shared_files from recipe/deploy/shared.php
.
Default value
[
'.env.local',
]
writable_dirs
Overrides writable_dirs from recipe/deploy/writable.php
.
Default value
[
'var',
'var/cache',
'var/log',
'var/sessions',
]
log_files
Default value
'var/log/*.log'
migrations_config
doctrine_schema_validate_config
bin/console
Default value
'{{bin/php}} {{release_or_current_path}}/bin/console'
console_options
Default value
return '--no-interaction';
Tasks
database:migrate
Migrates database.
doctrine:schema:validate
Validate the Doctrine mapping files.
deploy:cache:clear
Clears cache.
deploy:dump-env
Optimize environment variables.
deploy
Deploys project.
This task is group task which contains next tasks: