Skip to content

Deplyment with Capfiony on Windows

mai 12, 2013

Usually, we need to transfer our code from development environment to the production environment e.g production server. In case a symfony 2 application this process could be the following :

Upload your code to the production server;

Update the project dependencies via Composer;

Update/migrate your database;

Clear the cache;

On of the best tools available for symfony 2 is « Capifony » that is built on top of Capistrano. This is an open source tool to use for easily deploying Rails applications but a customize version called « Capifony » is published by symfony community to deploy symfony 1 and 2 applications.

While most of recipes deal with linux environments, I try to provide a simple guide to build Capifony in Windows to deploy your Symfony2 applications from Windows to a linux based server like debian.

Use Git Bash as the unique shell for your projects.

– Production server ready with ssh access.
– Git repository on your local computer or distant server
– tar package installed

1) Install Git for Windows
– download and install msysGit from official Git site :

2) Install Ruby
– download and install Rubyinstall for Windows :

3) Install Capifony
– open a Windows command prompt with Ruby
– install Capifony with this command :
gem install capifony

4) Setup local project
cd path/to/your/project
capifony .

5) Configure to deploy
There is 2 modes available; directly from git repository or via copy from local machine.
– Edit ./app/config/deploy.rb file :

set :application, "myappli"
set :domain,      ""
set :user,        "username"
set :use_sudo,    false

set :repository,  "ssh://#{domain}:/var/repo/#{application}.git"
set :scm,         :git
set :deploy_to,   "/var/www/#{application}"

set :app_path,    "app"
set :model_manager, "doctrine"

role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain                         # This may be the same as your `Web` server
role :db,         domain, :primary => true       # This is where Symfony2 migrations will run

set  :keep_releases,  3

logger.level = Logger::MAX_LEVEL

set :shared_files,        ["app/config/parameters.yml"]
set :shared_children,     [app_path + "/logs", web_path + "/uploads", "vendor"]
set :use_composer, true
set :update_vendors, true

# Symfony2 >= 2.1
before 'symfony:composer:update', 'symfony:copy_vendors'

namespace :symfony do
  desc "Copy vendors from previous release"
  task :copy_vendors, :except => { :no_release => true } do
    if Capistrano::CLI.ui.agree("Do you want to copy last release vendor dir then do composer install ?: (y/N)")
      capifony_pretty_print "--> Copying vendors from previous release"

      run "cp -a #{previous_release}/vendor #{latest_release}/"

5) Setup production server
– run this command on local project directory :
cap deploy:setup

– create server side « parameters.yml » in ./shared/app/config/ folder containing at least this parameter :

# /var/www/myappli/shared/app/config/parameters.yml
    secret: ThisTokenIsNotSoSecretChangeIt

6) Check if everything is ok to deploy
cap deploy:check

7) Deploy it !
cap deploy

8) Configure production server parameters
– Edit ./shared/app/config/parameters.yml file and add all necessary parameters e.g database connection.


From → Symfony2

Laisser un commentaire

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )


Connexion à %s

%d blogueurs aiment cette page :