Skip to content

Instantly share code, notes, and snippets.

@jmather
Created September 13, 2012 16:25
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jmather/3715541 to your computer and use it in GitHub Desktop.
Save jmather/3715541 to your computer and use it in GitHub Desktop.
Spiffy capistrano config for composer based projects
after "deploy", "deploy:cleanup"
after "deploy:update_code", "composer:install"
before "composer:install", "composer:copy_vendors"
after "composer:install", "phpunit:run_tests"
namespace :composer do
desc "Copy vendors from previous release"
task :copy_vendors, :except => { :no_release => true } do
run "if [ -d #{previous_release}/vendor ]; then cp -a #{previous_release}/vendor #{latest_release}/vendor; fi"
end
task :install do
run "sh -c 'cd #{latest_release} && curl -s http://getcomposer.org/installer | #{php_bin}'"
run "sh -c 'cd #{release_path} && ./composer.phar install'"
end
end
namespace :phpunit do
desc "Test before making live"
task :run_tests, :roles => :app do
run "cd #{latest_release} && #{phpunit_bin}"
end
end
@fkrauthan
Copy link

You should add a composer.phar check if its available and add #{php_bin} before you call composer.phar

@jeffbyrnes
Copy link

You might also want to check out roots/capistrano-composer.

@cbiggins
Copy link

@jeffbyrnes that works for cap 3 only. This snippet will work with cap 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment