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

Bartosz Sosna Blog

Bartosz Sosna Blog

PHP BLOG

Capistrano – PHP, deploy without stressful
Capistrano, Get Noticed 2017, PHP

Capistrano – PHP, deploy without stressful

Capistrano – PHP

Today, when everybody applies “Continuous Delivery” programmers must make changes frequently and delivery process can be stressful. Programmers try to make delivery process maximal simple and painless. Today have they already many tools to delivery. One of them is written in Ruby “Capistrano”. And team Capistrano – PHP work great!

Capistrano based on git and SSH. Nothing stands in the way of a use Capistrano to work with PHP projects.

If you need back to last revision, then you can make this effortless. Default on the server Capistrano storage 5 last versions. Actual version can you find in “current” folder.

Easy change the last version is not the only advantage of Capistrano. We can write special scripts (called Tasks) and run some scripts after (e.g. composer) or before (e.g. test) delivery. For this must we use Hooks.

What we need to work with Capistrano

Development environment – git, Capistrano.
Staging environment – git (We install Capistrano only on Development environment)

Installation

If you don’t develop in Ruby, then you’ll install first ruby and gem. Next, can you install Capistrano:

gem install capistrano

Are you ready? Now can you use Capistrano in your project:

cap install

Configure

To configure Capistrano need we 3 files:

config/deploy.rb -> settings for all environments

config/deploy/production.rb -> settings only for production environment (imports settings from config/deploy.rb)

config/deploy/staging.rb -> only for staging environment (imports settings from config/deploy.rb)

deploy.rb

In config/deploy.rb file must we set:

Project name:

set :application, "project name"

Git repository (np. Github or Bitbucket):

set :repo_url, "git@url:user/reponame.git"

Make sure that all servers have a generated SSH keys and have access to the git repository.

The path to deploy on staging and production servers:

set :deploy_to, "/path/to/your/project/catalog/"

staging.rb and production.rb

Next in config/deploy/staging.rb and config/deploy/production.rb files set SSH settings:

role :web, %w{username@111.222.333.444}

First deploy

Everything is ready. You can send changes to staging server:

cap staging deploy

Project in the latest version should be here:

/path/to/your/project/catalog/current/

If you want to send the changes on a production server, then you’ll use:

cap production deploy

Rollback

If you need back the changes, then you’ll use:

cap production/staging deploy:rollback

In the future will I write how to use Hooks for better automation.

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 March 16, 2017 / 1499 Views
Tags | capistrano, 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

how to work faster with phpstorm

How to work faster with PhpStorm

March 26, 2017

PHP coding standards – the first steps

April 22, 2017
Top 5 PhpStorm shortcuts

Top 5 PhpStorm useful shortcuts

April 9, 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