• Home
  • Get Noticed 2017
  • PHP
  • Quick Tips
  • Contact
  • About me

Bartosz Sosna Blog

Bartosz Sosna Blog

PHP BLOG

How to add tasks to capistrano
Capistrano, Get Noticed 2017, PHP, Quick Tips

How to add tasks to capistrano

How to add tasks to Capistrano

I wrote in post Capistrano – PHP, deploy without stressful how to install and make first deploy. In this post I want show you how to add tasks to capistrano.

When we send new code version to test or production server we need often to run some script to upload new database schema or update vendor folder with composer. That all can make Capistrano automatically. You need to add some script to config file:

namespace :deploy do
  desc "Build";
  after :updated, :build do
    on roles(:web) do
      within release_path do
        execute 'composer', 'install --no-dev --quiet'
        execute 'php', 'vendor/bin/phinx', 'migrate', '-e', 'testing', raise_on_non_zero_exit: false
      end
    end
  end
end

Capistrano after update execute two scripts: composer install and phinx to migrate database. If you need you can add another tasks for example delete cache or run tests scripts.

You can run hooks before update. More about hooks:
http://capistranorb.com/documentation/getting-started/before-after/

Troubleshooting

PHP is on my hosting not install in the standard place and I can’t run composer:

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as bsosna: composer exit status: 127
composer stdout: Nothing written
composer stderr: /usr/bin/env: php: No such file or directory

The solution is simple. If you have this error you must add php path to composer command:

SSHKit.config.command_map[:composer] = "/usr/local/YOUR_PHP_PATH/bin/php /usr/local/bin/composer"

Thanks "rob-gordon" for this solution.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)

Related

Written by Bartosz Sosna in May 5, 2017 / 1956 Views
Tags | composer, get notice 2017, php
AUTHOR
Bartosz Sosna

I'm Web and App developer. I love gadgets and new technologies. I'm also productivity freak.

You Might Also Like

“Image Optimizer API” is ready

May 21, 2017

PHP coding standards – the first steps

April 22, 2017

Why did I choose Slim Framework

March 19, 2017

No Comment

Please Post Your Comments & Reviews
Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Previous Post
Next Post

Serach

Newsletter

Latest Posts

  • API, Get Noticed 2017, PHP“Image Optimizer API” is ready“Get Notice 2017” contest is over My project “Image Optimizer…May 21, 2017
  • Get Noticed 2017, Quick Tips, zshZ shell (zsh) – better bashWhy zsh is better? I use console from years and…May 18, 2017
  • API, Get Noticed 2017, Quick TipsPostman – powerful tool to work with APIPostman – powerful tool to work with API I’m creating…May 7, 2017
  • Capistrano, Get Noticed 2017, PHP, Quick TipsHow to add tasks to capistranoHow to add tasks to Capistrano I wrote in post…May 5, 2017
  • Get Noticed 2017, MySQL, PHP, Quick TipsPhinx – PHP database migrationWhat is “database migration” I meet migrations first time in…April 30, 2017

STAY UPDATED

About Me

About Me

Web and App developer.

I'm Web and App developer. I love gadgets and new technologies. I'm also productivity freak.

About me (de)

Latest Posts

  • API, Get Noticed 2017, PHP“Image Optimizer API” is ready“Get Notice 2017” contest is over My project “Image Optimizer…May 21, 2017
  • Get Noticed 2017, Quick Tips, zshZ shell (zsh) – better bashWhy zsh is better? I use console from years and…May 18, 2017
  • API, Get Noticed 2017, Quick TipsPostman – powerful tool to work with APIPostman – powerful tool to work with API I’m creating…May 7, 2017
  • Capistrano, Get Noticed 2017, PHP, Quick TipsHow to add tasks to capistranoHow to add tasks to Capistrano I wrote in post…May 5, 2017
  • Get Noticed 2017, MySQL, PHP, Quick TipsPhinx – PHP database migrationWhat is “database migration” I meet migrations first time in…April 30, 2017
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

FOLLOW ME ON TWITTER

  • W końcu MacBook Pro bez bezużytczego touch bara? https://t.co/5tweGBUxP28 days ago
  • Ostatnio dodałem wpis o tym jak zintegrować PhpStorm z WSL2 i Docker, a dzisiaj powstał nowy wpis jak taki zestaw z… https://t.co/fcbezzzy5L23 days ago
Bartosz Sosna Blog

Copyright © Bartosz Sosna