diff --git a/templates/php/drupal/.env.example.twig b/templates/php/drupal/.env.example.twig index 4ce83b2..fddb10f 100644 --- a/templates/php/drupal/.env.example.twig +++ b/templates/php/drupal/.env.example.twig @@ -14,3 +14,7 @@ export DRUSH_OPTIONS_URI="https://${COMPOSE_PROJECT_NAME}.docker.localhost" export MYSQL_DATABASE=app export MYSQL_PASSWORD=app export MYSQL_USER=app + +export DB_NAME="$MYSQL_DATABASE" +export DB_PASSWORD="$MYSQL_PASSWORD" +export DB_USER="$MYSQL_USER" diff --git a/templates/php/drupal/run.twig b/templates/php/drupal/run.twig index 6f866ba..ab2bc51 100755 --- a/templates/php/drupal/run.twig +++ b/templates/php/drupal/run.twig @@ -53,6 +53,13 @@ function composer { _exec php composer "${@}" } +# Connect to the database. +function db { + [[ -f ".env" ]] && source .env + + docker compose exec database mysql -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" +} + function drush { _exec php drush "${@}" }