tl;dr I have an opinionated set up when it comes to Backdrop CMS development; the serundeputy/backdrop-starter allows me to achieve that quickly
What am I after?
- Nested web root
- config dirs outside the webroot
- Automated deploys w/ laravel/envoy and lando
- A useful .gitignore
- composer dependencies included and spun up right away
- A subtheme of basis right away
- Quickly installed project ready for development with settings.local.php
How do I achieve the setup?
First clone down the serundeputy/backdrop-starter repo into a directory for your new project (let's call this project hot-tamale):
git clone email@example.com:serundeputy/backdrop-starter.git hot-tamale
That gets the backdrop-starter code into a directory called hot-tamale on my computer. Now let's get spun up:
cd hot-tamale rm -rf .git cp .example.env .env
Now open the .env file in your editor and fill in the ENV variables with the values for your server.
# The password for your database on the server LP_DB_PWD= # The database name for this project LP_DB= # project root on the server something like /var/www/hot-tamale.com LP_PROJECT_ROOT= # site root for this backdrop-starter config /var/www/hot-tamale.com/web LP_SITE_ROOT= # path to the db.sql file for lando pull command /home/ME/backups/hot-tamale/db.sql LP_DB_BACK_PATH= # path for lando pull to get the f.tgz files assets backup: /home/ME/backups/hot-tamale/files/f.tgz LP_FILES_BACK_PATH= # the ssh string for your server LP_SSH_CMD=USERNAME@IPADDRESS TZ=America/New_York
Now open the .lando.yml in your editor and replace NEW_PROJECT string everywhere in the file with your project name, in our case hot-tamale:
name: hot-tamale recipe: backdrop config: webroot: web via: nginx database: mariadb:10.3 php: 7.3 backdrush: 1.x-1.x xdebug: true env_file: - .env services: appserver: run_as_root: - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone run: - composer install tooling: drush: service: appserver cmd: drush --root=/app/web --uri=https://hot-tamale.lndo.site yarn: service: node cmd: yarn lighthouse: service: node cmd: /app/node_modules/.bin/lighthouse envoy: service: appserver pull: service: appserver description: Pull and import the database and files from production. cmd: - appserver: envoy run pull - database: /helpers/sql-import.sh db.sql - appserver: rm db.sql - appserver: rm -rf /app/web/files - appserver: tar xvzf f.tgz -C /app/web - appserver: rm f.tgz deploy: service: appserver description: Deploy to production cmd: - appserver: envoy run deploy --branch=master
This .lando.yml is configured for drush version I want and to know about the nested web root. Installs my composer dependencies automatically and has the tooling set up for lando pull and lando deploy commands.
Now we can start the project and get our backdrop code:
lando start lando drush dlb backdrop --path=web
Now that we have our backdrop code base tell settings.php to look for our config outside of the web root by setting the $config_directories values:
$config_directories['active'] = '../config/active'; $config_directories['staging'] = '../config/staging';
Now copy our pre-configured settings.local.php into place:
cp settings.local.php web/
Here is the contents of settings.local.php
<?php // Caching $config['system.core']['cache'] = FALSE; $config['system.core']['preprocess_css'] = FALSE; $config['system.core']['preprocess_js'] = FALSE;
these settings will disable cacheing for our local development.
Now install backdrop to get our project up and running:
lando drush si --db-url=mysql://backdrop:backdrop@database/backrop
Now create our basis subtheme:
lando drush sb --name=hot_tamale
Now head to your URL https://hot-tamale.lndo.site enable our new theme and we have everything we need to start development on our new Backdrop CMS project!
That is my process for getting new projects up and running quickly. Like I said it is opinionated, so if your opinions match mine you can use this process too! If not you can either file in issue in the serundeputy/backdrop-starter issue queue or fork it and morph it into a starter kit that more closely matches your opinions, either way I hope this is helpful.