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-appin the current directory:docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/opt" -w /opt laravelsail/php84-composer:latest laravel new example-appcdinto a newly created directorycd example-appInstall Laravel Sail. Notice
-itflags 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.