Skip to content

Instantly share code, notes, and snippets.

@hatamiarash7
Created July 4, 2022 13:54
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 hatamiarash7/15a25d302ccea55417a4960e9c96fbc1 to your computer and use it in GitHub Desktop.
Save hatamiarash7/15a25d302ccea55417a4960e9c96fbc1 to your computer and use it in GitHub Desktop.
Create Laravel project using Sail
docker info > /dev/null 2>&1
# Color codes
RED='\033[1;31m'
LIGHT_CYAN='\033[1;36m'
NC='\033[0m'
# Ensure that Docker is running...
if [ $? -ne 0 ]; then
echo -e "${RED}Docker is not running."
exit 1
fi
# Ensure that project name is provided...
if [ -z "$1" ]; then
echo -e "${RED}Please provide a project name."
exit 1
fi
# Install project...
docker run --rm \
-v "$(pwd)":/opt \
-w /opt \
laravelsail/php81-composer:latest \
bash -c "laravel new $1 && cd $1 && php ./artisan sail:install --with=mysql,redis,mailhog,selenium"
cd $1
echo ""
# Run
if sudo -n true 2>/dev/null; then
sudo chown -R $USER: .
echo -e "${LIGHT_CYAN}Get started with:${NC} cd $1 && ./vendor/bin/sail up"
else
echo -e "${LIGHT_CYAN}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 "${LIGHT_CYAN}Thank you! We hope you build something incredible. Dive in with:${NC} cd $1 && ./vendor/bin/sail up"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment