Symfony3 Deployment example with Capistrano

Automatic deployment is super nice way to deliver software. In the past I’ve successfully used Capifony (Symfony-o-centric Capistrano 2.x gem) for deployments. Now as Symfony3 is out with an updated structure, Capifony does not handle it anymore (or a bit of coding sweat is required) – because it’s not maintained anymore. So I’ve decided to stick with it’s ancestor – Capistrano. So lets’ start.

P.S. This is based on Capistrano v3 now.

Requirements

Gemfile:

Run:

After success, let’s start configuring Capistrano:

After successful installation there should be some new files. config folder should now contain deploy.rb and deploy folder.

Configure deployment:

config/deploy.rb:

Configure environments to deploy to – config/deploy/production.rb:

As you can definitely tell, I used lots of defaults. I am using private-key authentication, so just that is required to be preconfigured. I deploy using my local machine as well as CI server, so it’s super easy and reusable piece of code.

Transfer parameters.yml for initial deployment:

In my case, it’s located in /home/sitename.com/shared/app/config/parameters.yml

After that, first successfull deployment can by performed:

… and then a sign of success:

Success! You have successfully released your first automated release via Capistrano in under 20s including migrations, composer installation and simple asset management.

C U,
ME

5 comments

  1. Hey Àngel,

    I’ve tried Capifony in the past for my older (Symfony 2.x) projects and it worked like a charm, no issues. But Capifony is not maintained anymore so it does not support new Symfony releases – meaning it’s your own effort to keep it running now :)

  2. Hey,

    use this example but got an error on after ‘deploy:starting’, ‘composer:install_executable’ task

    The message is: The deploy has failed with an error: wrong number of arguments (0 for 1+)

     

    any idea?

  3. How Capistrano is different from Envoyer. I only prefer using Envoyer to deploy the symfony app because it makes the process easier and much quicker. Envoyer is a Laravel product, but it can be used with any PHP app. Apart from quick deployment, there is also benefit of zero downtime deployment. This means if you use Envoyer with push a branch from git, the new changes will be updated on your website without any downtime. Source: https://www.cloudways.com/blog/automate-symfony-deployment-through-envoyer/

Leave a Reply

Your email address will not be published. Required fields are marked *