Skip to content

Instantly share code, notes, and snippets.

@jameswilson
Created September 11, 2023 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameswilson/fd3731ac8b9eafab686fe7103adc7f92 to your computer and use it in GitHub Desktop.
Save jameswilson/fd3731ac8b9eafab686fe7103adc7f92 to your computer and use it in GitHub Desktop.
joachim-n/drupal-core-development-project for DDEV
#!/usr/bin/env bash
#
# Create a local environment leveraging DDEV for the specified Drupal core version.
#
# Installation:
# store this file in your /usr/local/bin or ~/bin and ensure it shows up in your $PATH
#
# Usage:
# ddev-drupal-core-install 11.x (bleeding edge)
# ddev-drupal-core-install 10.2.x
# ddev-drupal-core-install 10.1.x
# ddev-drupal-core-install 9.5.x
#
# Forked from https://github.com/bbrala/local-dotfiles/blob/master/.local/bin/ddev-drupal-core-install
# and modified to support https://github.com/joachim-n/drupal-core-development-project
set -x
VERSION=${1:-9.5.x}
PROJECTS_PATH=${PROJECTS_PATH:-$HOME/App/Contrib}
DDEV_MAJOR_VERSION=${VERSION%.*.*}
if [[ ${DDEV_MAJOR_VERSION} =~ \. ]]; then
DDEV_MAJOR_VERSION=10
fi
mkdir drupal-core-${VERSION//./-}
cd drupal-core-${VERSION//./-}
ddev config \
--project-type=drupal${DDEV_MAJOR_VERSION} \
--project-name=drupal-core-${VERSION//./-} \
--docroot=web \
--create-docroot
ddev remove
ddev start
ddev auth ssh
ddev composer create joachim-n/drupal-core-development-project --no-interaction
cp sites/example.settings.local.php sites/default/settings.local.php
ddev drush --yes site:install standard \
install_configure_form.site_default_country=US \
install_configure_form.date_default_timezone=America/New_York \
install_configure_form.enable_update_status_module=1 \
install_configure_form.enable_update_status_emails=NULL \
--locale="en" \
--site-name="Drupal ${VERSION}" \
--site-mail="admin@example.com" \
--account-name="admin" \
--account-pass="admin" \
--account-mail="admin@example.com" \
--db-url="mysql://db:db@db/db"
cd web/
cp core/phpunit.xml.dist core/phpunit.xml
sed -i 's|name="SIMPLETEST_BASE_URL" value=""|name="SIMPLETEST_BASE_URL" value="https://drupal-core-'${VERSION//./-}'\.ddev\.site"|g' core/phpunit.xml
sed -i 's|name="SIMPLETEST_DB" value=""|name="SIMPLETEST_DB" value="mysql://db:db@db/db"|g' core/phpunit.xml
sed -i 's|name="BROWSERTEST_OUTPUT_DIRECTORY" value=""|name="BROWSERTEST_OUTPUT_DIRECTORY" value="../sites/simpletest/browser_output"|g' core/phpunit.xml
sed -i 's|<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->|<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>|g' core/phpunit.xml
set +x
echo "
Installation successful!
$(ddev describe)
Next steps:
1. Open the following link in a browser to login:
$(ddev drush uli)
2. Drop into the project folder on the command line:
cd ${PROJECTS_PATH}/drupal-core-${VERSION//./-}
3. Add, enable, & configure other useful developer dependencies. E.g.,
ddev composer require drupal/admin_toolbar
ddev composer require drupal/coder
ddev composer require mglaman/drupal-check
ddev composer require drupal/devel
ddev composer require drupal/devel_php
ddev composer require drupal/webprofiler
ddev composer require drupal/examples
ddev composer require drupal/stage_file_proxy
ddev composer require drupal/backup_migrate
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment