drush serve
FTW
- Less CPU / Ram usage = blazing fast setup 🚀
- Quickly test a project feature with a clean install
- Start a POC or test a distribution
- Use SQLite or MySQL on local host
- Quickly test against multiple PHP versions
- A minimal Drupal 9 local development environment - Install Drupal locally in 3 commands with minimal dependencies (= PHP and Composer)
- Homebrew multiple PHP versions
- The environment is exactly the same as stage and prod.
- Run extra services like Varnish, Solr, Elasticsearch, Mailhog, ...
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
include $app_root . '/' . $site_path . '/settings.local.php';
}
// With MySQL on Lando.
if (getenv('LANDO_HOST_IP') === 'host.docker.internal' &&
file_exists($app_root . '/' . $site_path . '/settings.lando.php')
) {
$databases['default']['default'] = [
'database' => 'drupal9',
'username' => 'drupal9',
'password' => 'drupal9',
'prefix' => '',
'host' => 'database',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
];
}
// With SQLite on local host.
else {
$databases['default']['default'] = [
'database' => 'sites/default/files/.sqlite',
'prefix' => '',
'namespace' => 'Drupal\\Core\\Database\\Driver\\sqlite',
'driver' => 'sqlite',
];
}
- Lagoon
- Lagoon with Lando = same Docker images and same services configuration
As a developer, my favourite features are
- Scalability
- PR environments
- CLI and UI
- GraphQL API e.g. for project tasks, environment variables, ...
- Simple "pipeline"
- Simple local/prod Varnish, Solr, Redis, ...
- Backups
- Slack notifications about the builds, with logs link
Install in 2 commands
lando start
lando drush si -y
tasks:
pre-rollout:
- run:
name: drush sql-dump
command: mkdir -p /app/web/sites/default/files/private/ && drush sql-dump --ordered-dump --gzip --result-file=/app/web/sites/default/files/private/pre-deploy-dump.sql.gz || true
service: cli
post-rollout:
- run:
name: drush cim
command: drush -y cim
service: cli
- run:
name: drush updb
command: drush -y updb
service: cli
- run:
name: drush cr
command: drush -y cr
service: cli
- Install relevant (aka non Lorem ipsum) test content also from configuration, while running
drush si
- Supports entity reference (Group, File, ...)
- Useful to scaffold a base for e.g. E2E or manual tests
Nodes
nid_limit=5 # Presumes that node ids are 1 to 5.
for i in $(seq 1 $nid_limit); do drush dcer node $i --folder=modules/custom/my_default_content/content; done
Terms
tid_limit=5 # Presumes that term ids are 1 to 5.
for i in $(seq 1 $tid_limit); do drush dcer taxonomy_term $i --folder=modules/custom/my_default_content/content; done
Menu links
mlcid_limit=5 # Presumes that menu link content ids are 1 to 5.
for i in $(seq 1 $mlcid_limit); do drush dcer menu_link_content $i --folder=modules/custom/my_default_content/content; done
cd web && ../vendor/bin/drush si -y standard --sites-subdir default --account-name admin --account-pass admin --existing-config
../vendor/bin/drush en nn_default_content -y