Setup Drupal (8/9) with Lando. Using Composer, xdebug and grumphp for code-quality tools
This project template provides a starter kit to manage drupal project with Lando, xdebug and grumphp.
It is set with most popular and used modules for drupal, such as devel, config_split, paragraphs, etc …
Table of Contents
First you need to install lando.
Note: You might need to install
docker
if you do not yet install it for your setup.
After that you clone this project and run
lando start
Note: Drupal will avalaible through
http://drupal-lando-boilerplate.lndo.site:8080/
.
To init/create drupal website :
lando site-install
All parameters about site installation (site name, admin login, etc …) are configured in .lando/settings/site_config.sh file.
To install php components, run
lando composer install
With composer require ...
you can download new dependencies to your
installation.
Example:
lando composer require drupal/devel:~1.0
To check component version, run
lando composer outdated
To update composer packages, run
lando composer update
If you need to apply patches (depending on the project being modified, a pull
request is often a better solution), you can do so with the
composer-patches plugin.
To add a patch to drupal module foobar insert the patches section in the extra
section of composer.json:
"extra": {
"patches": {
"drupal/foobar": {
"Patch description": "URL or local path to patch"
}
}
}
Use /patches directory to put patches files.
This project has a php with an xdebug installed and activated, ready to use.
To set it up with the IDE : Lando + xdebug + phpstorm
Use config_split module to manage configurations.
There are three splits of configurations :
$config['config_split.config_split.dev']['status'] = TRUE;
$config['config_split.config_split.hors_prod']['status'] = FALSE;
$config['config_split.config_split.prod']['status'] = FALSE;
To import
lando drush cim -y
To export
lando drush csex -y
You need to manage po files to configure multilanguage site case.
To check for updates
lando drush locale-check
To update
lando drush locale-update
To reinstall composer package, remove vendor, core and contrib modules/themes :
lando composer-reset
To install or update local environment : install new components, update database, import configurations, etc …
lando site-update
To reset database
lando drush db-import <your-dump>.sql
Phpcs is necessary to control and continue coding in good practice.
The verification is done in the /www/modules/custom directory.
lando phpcs
lando phpcs-fix
lando phpcs-summary
grumphp is used to check the quality of codes before commits.
PhpLint, PhpUnit and PhpCs are launched at each commit.
Note: phpro/grumphp is fixed in 0.18.1 version because at the moment I write this doc, the recent version of grumphp is not compatible (has conflit) with some drupal dependencies.