Skip to content

Instantly share code, notes, and snippets.

@emilorol
Created October 11, 2024 21:29
Show Gist options
  • Save emilorol/24376fea17b9abede30112e201183a75 to your computer and use it in GitHub Desktop.
Save emilorol/24376fea17b9abede30112e201183a75 to your computer and use it in GitHub Desktop.
Drupal composer installation helper. Pick version and path
#!/bin/bash
# Prompt for version if not provided as the first parameter
if [ -z "$1" ]; then
read -p "Enter the Drupal version you would like to install (e.g., 8, 9, 10, 11): " version
else
version=$1
fi
# Prompt for installation directory if not provided as the second parameter
if [ -z "$2" ]; then
read -p "Enter the installation directory (default: new_dir): " install_dir
install_dir=${install_dir:-new_dir} # Fallback to "new_dir" if not provided
else
install_dir=$2
fi
# Ensure the version is valid
if [[ "$version" =~ ^(8|9|10|11)$ ]]; then
composer create-project drupal-composer/drupal-project:"$version".x-dev "$install_dir" --no-interaction
else
echo "Invalid version. Please enter 8, 9, 10, or 11."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment