Use case: Develop Backdrop sites and be able to continuously deploy patches, updates and features cleanly and easily on Pantheon. We, the Backdrop Community, hope to offer Backdrop local drush out of the box in the near future, but for now here are the steps to get you going on Pantheon, Terminus, Drush and Backdrop CMS right now!
Install Backdrop CMS with terminus:
Use the terminus upstreams list command to see the available upstreams Pantheon has to offer. Among them you will see Backdrop CMS.
| bf703821-4c18-45a1-88b8-3d9ec302273d | Backdrop | vanilla | core | backdrop |
That first big string there is the upstream ID for Backdrop: bf703821-4c18-45a1-88b8-3d9ec302273d. We'll use that to quickly spin up a Backdrop site on pantheon. Issue this command terminus:
sites create --upstream=bf703821-4c18-45a1-88b8-3d9ec302273d --site="The Backdrop" --org=<id>
This will install Backdrop on Pantheon. The --org=<id> part is optional, but for example if you work for an agency you can provide the org id to make the site available to your team. The output from the terminus command will look something like this:
Now login into your Pantheon account and visit your dashboard and your new site will be available to you! Visit the new site and go through the installation steps. Woohoo fresh Backdrop installation on Pantheon! Now from your site dashboard get the git clone command and clone your site locally to get ready for development:
Issue that command in your terminal to clone your Pantheon Backdrop CMS install to your local. Out of the box the Pantheon instances are using PHP 5.5 we can configure this using a pantheon.yml file. The contents of the YAML file control certain configuration aspects of your site. The one that we are concerned about here is PHP 7. Here are the contents of the pantheon.yml file:
api_version: 1 php_version: 7.0
Add this file to your git repo and push it up to your master branch. When pantheon picks up the deploy #voila you are on PHP 7! Woooooot; celebrate. Visit /admin/reports/status/ to verify your PHP version. The full details of configuration options you can use on Pantheon can be found here: pantheon.yml.
Now to get our site local drush up and running. First download drush 8.x into a drush directory inside of your local copy of your site's git repo. That will put a drush executable file in this location: BACKDROP_ROOT/drush/drush/drush Then checkout the 8.x branch and use composer to install drush. Here are the steps:
- mkdir drush
- cd drush
- git clone https://github.com/drush-ops/drush.git
- cd drush
- git checkout 8.x
- composer install
Now we have drush installed! You are going to want to commit drush, the vendor directory (composer makes that). The git clone of drush includes a .gitignore file which is out of the box ignoring the vendor directory, so we need to remove that entry before we can commit it to the repo along with the site local drush. Open the .gitignore file in your favorite text editor and remove the line for vendor it was line 2 for me. I'm also going to remove the .git directory from the drush directory with rm -r drush/drush/.git (you may have to use sudo) if you are in your BACKDROP_ROOT. Steps:
- Open the BACKDROP_ROOT/drush/drush/.gitignore file and remove the line for vendor
- Remove the BACKDROP_ROOT/.git directory: rm -r BACKDROP_ROOT/drush/drush/.git
- Commit it all to the repo and deploy to Pantheon
- git add -A
- git commit -m "Adding drush local to my pantheon site."
- git push origin master
Next we need to get the Backdrop drush extension in order to allow drush to work with Backdrop. We need to put the extension in the BACKDROP_ROOT/drush/drush/commands directory. Then commit this code to the repo and deploy. Here are the steps for that:
- cd BACKDROP_ROOT/drush/drush/commands
- mkdir backdrop
- cd backdrop
- git clone firstname.lastname@example.org:backdrop-contrib/drush.git .
- notice the '.' at the end to clone into the current directory
We want to remove the .git directory from the bakdrop directory too so that we can easily commit it to your Pantheon repo.
- rm -r BACKDROP_ROOT/drush/drush/commands/backdrop/.git
- git add -A
- git ci -m "Istalling the backdrop drush extension."
At this point we have all the code in place we need to use the Backdrop site local drush, but we need to tell Pantheon to use Drush 8 to be compatible with the backdrop extension. Here is the command to set your Pantheon to Drush 8: terminus site set-drush-version --version=8. Phew! Now you should be able to run drush commands against your Backdrop site on Pantheon! For example:
- terminus --site=the-backdrop drush "cc all"
- terminus --site=the-backdrop drush "cron"
- terminus --site=the-backdrop "updb -y"
Should all work nicely and help with your deploy workflows! Profit! You can use this workflow to spin up as many Backdrop sites as you have clients and even extend it to automate your deploy tasks with terminus. Follow us on twitter @backdropcms, @serundeputy