- capify-php - is a Capistrano extension for PHP without the rails tasks.
capify-php is simple to install, it cleanly extends Capistrano, keeping your deploy.rb tidy.
- Same rollback you get from Capistrano
- Easy to configure
- Supports exporting PHP libraries from any Git source
- Setup multiple environments with tasks inside your deploy.rb. (example below)
If you don't have capistrano and/or capify-php installed:
# gem install capistrano # gem install capify-php -s http://gemcutter.org
For every application you'll want to deploy:
# cd /path/to/app && capify .
This will create the following files in your project (don't forget to commit them!):
Prepend your config/deploy.rb with the following lines:
require 'rubygems' require 'capify-php'
And make sure you start capify-php on the last line of that same file:
You should then be able to proceed as you usually would. To familiarise yourself with the now modified list of tasks, you can get a full list with:
$ cap -T
Before continuing, some changes to config/deploy.rb are necessary. First, your project's name:
set :application, "your_app_name"
Next, setting up the Git repository (make sure it's accessible by both your local machine and server your are deploying to):
set :repository, "email@example.com:path/to/repo"
Now, to deploy from Git, and by following GitHub's suggestion (they must know what they are talking about), add a user (defaults to deploy by capistrano.php's recipe) to your server(s) just for deployments. In this example, I will be using SSH keys instead of getting a Git password prompt. Local user's SSH key must be added to deploy's ~/.ssh/authorized_keys for this to work as described.
ssh_options[:forward_agent] = true
We need to tell it where to deploy, using what methods:
You can change the default values for the following variables also:
set :php_lib_branch, "v2.0.1" set :php_lib_repo, "https://github.com/symfony/symfony.git" set :php_lib_dir, "symfony"
The first time you are deploying, you need to run:
# cap deploy:setup
That should create on your server the following directory structure:
[deploy_to] [deploy_to]/releases [deploy_to]/shared [deploy_to]/shared/cakephp [deploy_to]/shared/system [deploy_to]/shared/tmp
# cap deploy
Which will change the directory structure to become:
[deploy_to] [deploy_to]/current -> [deploy_to]/releases/20091013001122 [deploy_to]/releases [deploy_to]/releases/20091013001122 [deploy_to]/releases/20091013001122/system -> [deploy_to]/shared/system [deploy_to]/releases/20091013001122/tmp -> [deploy_to]/shared/tmp [deploy_to]/shared [deploy_to]/shared/cakephp [deploy_to]/shared/system [deploy_to]/shared/tmp
Multiple environments 1 deploy.rb
desc "Run tasks in production enviroment." task :production do # Production nodes role :web, "webserver-one-hostname-or-ip" role :app, "webserver-one-hostname-or-ip" role :web, "webserver-two-hostname-or-ip" role :app, "webserver-two-hostname-or-ip" set :branch, "master" end desc "Run tasks in staging enviroment." task :staging do # Staging nodes role :web, "staging-hostname" role :app, "staging-hostname" role :db, "staging-hostname", :primary=>true set :branch, "develop" end
# cap staging deploy or # cap production deploy
Patches & Features
- Mod, fix
- Test - this is important, so it's not unintentionally broken
- Commit - do not mess with license, todo, version, etc. (if you do change any, make them into commits of their own that I can ignore when I pull)
- Pull request - bonus point for topic branches