How to start a new Laravel project with Laravel Sail

Here are 4 quick commands you need to run to kick-start a Laravel project in Laravel Sail, even without PHP running on your local machine. The only thing you need to do before is to make sure you have docker installed on your machine, and added sail
alias, as described in Laravel Sail docs. I’m running these commands in WSL2 on Windows 11, but they should work on Linux or Mac too.
Start a new Laravel app called
example-app
in the current directory:docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/opt" -w /opt laravelsail/php84-composer:latest laravel new example-app
cd
into a newly created directorycd example-app
Install Laravel Sail. Notice
-it
flags that allow us to run a container in the interactive mode:
docker run -it --rm -u "$(id -u):$(id -g)" -v "$(pwd):/opt" -w /opt laravelsail/php84-composer:latest php artisan sail:install
Select sail services as needed.
Build the container:
sail build
And you’re done.
Subscribe to my newsletter
Read articles from Amadeusz Annissimo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
