copy and paste the script. Make sure docker is running
You can change the 84 to another version of php, for exampe 82 for php 8.2, etc
#!/bin/bash | |
APP_NAME="my-laravel-app" # Change this to your desired project name | |
docker info > /dev/null 2>&1 | |
# Ensure that Docker is running... | |
if [ $? -ne 0 ]; then | |
echo "Docker is not running." | |
exit 1 | |
fi | |
docker run --rm --interactive --tty \ | |
--pull=always \ | |
-v "$(pwd)":/opt \ | |
-w /opt \ | |
-e APP_NAME="$APP_NAME" \ | |
laravelsail/php84-composer:latest \ | |
bash -c "laravel new \$APP_NAME --no-interaction && cd \$APP_NAME && php ./artisan sail:install --with=mysql,redis,meilisearch,mailpit,selenium" | |
if [ -d "$APP_NAME" ]; then | |
cd "$APP_NAME" | |
else | |
echo "Laravel installation failed. Check the logs above." | |
exit 1 | |
fi | |
CYAN='\033[0;36m' | |
LIGHT_CYAN='\033[1;36m' | |
BOLD='\033[1m' | |
NC='\033[0m' | |
echo "" | |
if command -v doas &>/dev/null; then | |
SUDO="doas" | |
elif command -v sudo &>/dev/null; then | |
SUDO="sudo" | |
else | |
echo "Neither sudo nor doas is available. Exiting." | |
exit 1 | |
fi | |
if $SUDO -n true 2>/dev/null; then | |
$SUDO chown -R $USER: . | |
echo -e "${BOLD}Get started with:${NC} cd $APP_NAME && ./vendor/bin/sail up" | |
else | |
echo -e "${BOLD}Please provide your password so we can make some final adjustments to your application's permissions.${NC}" | |
echo "" | |
$SUDO chown -R $USER: . | |
echo "" | |
echo -e "${BOLD}Thank you! We hope you build something incredible. Dive in with:${NC} cd $APP_NAME && ./vendor/bin/sail up" | |
fi |
docker run --rm --interactive --tty \ | |
--pull=always \ | |
-v "$(pwd)":/opt \ | |
-w /opt \ | |
laravelsail/php84-composer:latest \ | |
bash -c "laravel new example-app" |