Skip to content

Instantly share code, notes, and snippets.

@max4kaps max4kaps/deploy.php
Created Aug 11, 2017

What would you like to do?
Example of deploy.php for deployer - Symfony 3.3 with tagging on each deployment
/* (c) Max Kapshtyk <>
* Feel free to use for own purposes, don't forget to setup your information.
* For the full copyright and license information, please view the LICENSE on our website
namespace Deployer;
use function Deployer\{host, task, run, set, get, add, before, after, upload, writeln};
require 'vendor/deployer/deployer/recipe/symfony3.php';
// Specify the repository from which to download your project's code.
set('repository', '');
set('dump_assets', true);
// Define a server for deployment.
->set('deploy_path', '/var/www/')
->set('branch', 'master')
->set('deploy_path', '/var/www/')
->set('branch', 'dev')
task('database:migrate', function () {
run('{{env_vars}} {{bin/php}} {{bin/console}} doctrine:migrations:migrate {{console_options}} --allow-no-migration');
})->desc('Run migrations on need');
task('database:fixture', function () {
// check if db exists
run('{{env_vars}} {{bin/php}} {{bin/console}} doctrine:fixtures:load {{console_options}}');
})->desc('Load data in db');
before('database:migrate', 'database:backup');
after('deploy:vendors', 'database:migrate');
* Dump all assets to the filesystem
task('deploy:assetic:dump', function () {
if (get('dump_assets')) {
run('{{env_vars}} {{bin/php}} {{bin/console}} assetic:dump {{console_options}} ');
})->desc('Dump assets');
* Dump all js translations
task('deploy:js-translation:dump', function () {
if (get('dump_assets')) {
run('{{env_vars}} {{bin/php}} {{bin/console}} bazinga:js-translation:dump {{console_options}} ');
})->desc('Dump all js translations, in 4bis we use bazinga');
before('deploy:assetic:dump', 'deploy:js-translation:dump');
// lovely tag in our repo
task('git:tag', function () {
$git = get('bin/git');
$release = get('release_name');
$date = run('date +"%Y%m%d%H%M%S"');
$stage = get('stage');
$releaseTag = $stage . '.' . $release . '.' . $date;
run("cd {{release_path}} && $git tag $releaseTag");
run("cd {{release_path}} && $git push origin --tags");
})->desc('Adding new deployment tag to repo');
task('nginx:reload', function () {
run("service nginx reload");
run('service php7.1-fpm restart');
})->desc('reload nginx for symlink to current');
after('deploy:unlock', 'git:tag');
after('deploy:unlock', 'nginx:reload');

This comment has been minimized.

Copy link

Martin1982 commented Feb 8, 2018

In line 46 ( a reference to database:backup is made. Using deployer ^0.6 this task is not available (I assume it should be a custom one).

Removing/commenting this line will run the deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.