This coming weekend is the Drupal Global Contribution Weekend where small local contribution groups volunteer their Drupal development at the same time throughout the world. This year there are local groups gathering in Canada, England, Germany, India, Russia, Spain, and the United States. You can check out the Drupical map to see if there is a local group near you, but if there isn’t, the contribute to accessibility group is meeting remotely.
If you have not contributed to Drupal core before, you’ll need need a couple things to get started:
- A user account on Drupal.org
- A computer with git installed
- A local development environment
- Knowledge of how to create and apply patches using git
Helpful Resources for Contributing to Drupal
- Search the Drupal 8 issue queue and use the 'Novice' tag to get started with contributing.
- When making a change to Drupal’s API you need to create a change record for Drupal core.
- Check out the guidelines on how to make a good issue.
- Chat with the Drupal community using Slack and speak to core maintainers directly in the
#contribute
channel. - Contribute to documentation on Drupal.org instead of writing code.
Setting up a Local Environment with Lando
To have a successful contribution weekend you need a solid local development environment. You can use any local environment you are comfortable with, but I recommend a local development environment named Lando which uses Docker containers under the hood.
Installing Lando
Lando works on latest versions of Linux, macOS, and Windows. As of writing this article, I recommend installing the latest release Beta 47 due to some regressions in the pre-release RC1.
Setting up Drupal
First you’ll need to clone the latest development branch of Drupal core locally using git. In your terminal, run:
$ git clone --branch 8.7.x https://git.drupal.org/project/drupal.git
Cloning into 'drupal'...
remote: Counting objects: 663588, done.
remote: Compressing objects: 100% (140811/140811), done.
remote: Total 663588 (delta 480786), reused 652577 (delta 471060)
Receiving objects: 100% (663588/663588), 144.13 MiB | 7.85 MiB/s, done.
Resolving deltas: 100% (480786/480786), done.
Checking out files: 100% (13558/13558), done.
Next move into into the newly created drupal
directory, create a .lando.yml
file, and add the following to the file:
name: drupal
recipe: drupal8
config:
webroot: .
php: "7.2"
xdebug: true
services:
appserver:
run:
- cd $LANDO_MOUNT && composer install
nodejs:
type: node:9
phpmyadmin:
type: phpmyadmin
tooling:
node:
service: nodejs
npm:
service: nodejs
To break down what’s happening here. We are running a local environment with Apache 2.4, PHP 7.2 (with xdebug), MySQL 5.6, NodeJS 9.x, and PHPMyAdmin. You can use the nodejs service to work with Drupal’s frontend components and the phpmyadmin service for a GUI to view the database schema.
Lando provides tooling which wraps command line utilities with the lando
command to run them in a Docker container. You can see what tooling is available by typing lando
in the terminal:
$ lando
Usage: lando <command> [args] [options] [-- global options]
Commands:
composer Run composer commands
config Display the lando configuration
db-export [file] Export database from a service
db-import [file] Import <file> into database service
destroy [appname] Destroy app in current directory or [appname]
drupal Run drupal console commands
drush Run drush commands
info [appname] Prints info about app in current directory or [appname]
init [method] Initialize a lando app, optional methods: github, pantheon
list List all lando apps
logs [appname] Get logs for app in current directory or [appname]
mysql Drop into a MySQL shell on a database service
node Run node commands
npm Run npm commands
php Run php commands
poweroff Spin down all lando related containers
rebuild [appname] Rebuilds app in current directory or [appname]
restart [appname] Restarts app in current directory or [appname]
share [appname] Get a publicly available url
ssh [appname] [service] SSH into [service] in current app directory or [appname]
start [appname] Start app in current directory or [appname]
stop [appname] Stops app in current directory or [appname]
version Display the lando version
Global Options:
--help, -h Show help
--verbose, -v, -vv, -vvv, -vvvv Change verbosity of output
You need at least one command before moving on
Next, let’s start Lando:
lando start
After Lando successfully starts, it will output all the URLs for your local environment.
Great, we have Lando setup and ready to run Drupal. Now we just need to define some settings for Drupal to run with Lando. Create a settings file located at sites/default/settings.php
with the following code:
<?php
if (getenv('LANDO_INFO')) {
$lando_info = json_decode(getenv('LANDO_INFO'), TRUE);
$databases['default']['default'] = [
'database' => $lando_info['database']['creds']['database'],
'username' => $lando_info['database']['creds']['user'],
'password' => $lando_info['database']['creds']['password'],
'prefix' => '',
'host' => $lando_info['database']['internal_connection']['host'],
'port' => $lando_info['database']['internal_connection']['port'],
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
];
// Config sync directory for Lando.
$config_directories[CONFIG_SYNC_DIRECTORY] = '/app/config/common';
// Default hash salt for Lando.
$settings['hash_salt'] = 'BfHE?EG)vJPa3uikBCZWW#ATbDLijMFRZgfkyayYcZYoy>eC7QhdG7qaB4hcm4x$';
// Allow any domains to access the site with Lando.
$settings['trusted_host_patterns'] = [
'^(.+)$',
];
}
Finally, let’s install Drupal. We’re going to add Drush to the project and use it to install Drupal with the standard installation profile:
lando composer require drush/drush:^9.4 && lando drush site:install standard --account-pass=admin --yes
You can now access your local installation of Drupal at https://drupal.lndo.site
. The username is admin and the password is admin.