LocalGov Drupal is an opensource Drupal distribution being built and maintained by UK Councils and Drupal developers. Its rationale: to pool knowledge resources to build a better publishing platform for local governments.
LocalGov's documentation explains how to set up LocalGov Drupal using Lando, a docker based tool to set up local development environments.
At TrainingCloud we prefer DDEV-local, a tool similar to Lando. Even though the company behind DDEV has announced their shutdown on May 15 2021, DDEV itself shows no signs of calling it quits.
This article assumes you've already set up DDEV-local itself. If you haven't, follow the DDEV-local installation instructions first and then continue reading this article.
For the purposes of this article:
- we'll name our project Weatherfield
- we refer to the DDEV-local tool simply as DDEV
- we place all our projects in our local
Step 1: Fetch the LocalGov Drupal source code
$ composer create-project --stability dev localgovdrupal/localgov-project weatherfield --remove-vcs
Step 2: Set up a DDEV instance
$ ddev config
When prompted by DDEV, provide the following values:
- site name:
- docroot location:
- project type:
→ site name is used as part of your local site's hostname
→ docroot location is where the actual Drupal site is located
→ project type tells DDEV how to configure the local hosting environment
Step 3: Tell Drupal to load DDEV settings instead of Lando settings
The Drupal settings file at
/sites/default/settings.php that comes with LocalGov Drupal loads `settings.lando.php' at the very end.
To replace that block at the end with the following:
→ this will try to load your custom local settings file, if you have one, and fall back to
settings.ddev.php, if you have one.
Step 4: Customise a few DDEV settings
- If your port 80 is already in use by another webserver or DDEV environment, DDEV will show an error when you try to start. When this happens, change the router (webserver) port:
→ choose any number, by convention in the 8000-8999 range
- DDEV automatically recreates ddev.settings.php after every restart. We personally don't like this because we tend to add more custom settings to
sites/default/settings.ddev.php, so we disable this feature:
- set Drupal's configuration management directory to
../config/sync, LocalGov Drupal's default config directory:
$settings['config_sync_directory'] = '../config/sync';
- set maximum error reporting and verbose error logging:
/** * Error reporting. * * As a developer it is useful to see all errors. If the site you are working * on has a lot of notice errors and you aren't able to fix them you can * suppress them by modifying E_ALL in error_reporting to: * E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED */ error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); /** * Show all error messages, with backtrace information. * * In case the error level could not be fetched from the database, as for * example the database connection failed, we rely only on this value. */ $config['system.logging']['error_level'] = 'verbose';
Step 5: Start DDEV
$ ddev start
Step 6: Install LocalGov Drupal from the command line
$ ddev exec drush si localgov -y
Step 7: Launch project in browser
$ ddev launch
→ opens a new tab in your default browser and loads your new LocalGov Drupal site. Imagine what you can do with all the time you saved by not having to copy/paste the project link into your browser by hand :)
If everything went well, you should see your new LocalGoc Drupal site waiting for you.
- Article image: TheOther Kev