Skip to content

Instantly share code, notes, and snippets.

@wffranco
Last active July 19, 2024 21:01
Show Gist options
  • Save wffranco/e6974f80ed4703ff45c540637a2c66a5 to your computer and use it in GitHub Desktop.
Save wffranco/e6974f80ed4703ff45c540637a2c66a5 to your computer and use it in GitHub Desktop.
Sail local command for laravel with php 8.3. It will run automatically the first `composer` installation if `vendor` folder is missing.
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"
if [ ! -e ./vendor ]; then
docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
laravelsail/php83-composer:latest \
composer install --ignore-platform-reqs
fi
if [ ! -f .env ]; then
cp .env.example .env
./sail artisan key:generate
fi
# if the first argument is "in:*", use it as service name, setting the APP_SERVICE environment variable
# example of usage: sail in:mysql mysql -u root -p
# useful if you use extra or non-default services in your docker-compose.yml
if [[ $1 == in:* ]]; then
export APP_SERVICE=${1:3}
shift
fi
./vendor/bin/sail $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment