Skip to content

Instantly share code, notes, and snippets.

@wffranco
Created May 22, 2023 00:45
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 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.1. Add `sail init`, allowing the first download of `vendor` folder (without it you can't run sail)
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"
#if the command is called with `init` param, or `vendor` folder is missing
if [ "$1" = "init" ] || [ ! -d vendor ]; then
#run laravel sail container to run `composer install`
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs
fi
if [ "$1" != "init" ]; then
./vendor/bin/sail $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment