Overview
Laravel Sail is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building Laravel applications without requiring prior Docker experience, and is a perfect fit for Statamic with a few tweaks.
At its heart, Sail is a docker-compose.yml
file and script that is stored at the root of your project. The sail script provides a CLI with convenient methods for interacting with the Docker containers defined by the docker-compose.yml
file.
Laravel Sail is supported on macOS, Linux, and Windows (via WSL2).
Since Sail is the starting point for a new Laravel app, we'll be installing Statamic into a fresh Laravel app.
Installing Docker
If you don't already have Docker installed, head to docker.com/get-started and download the latest version for your OS.
Installing Laravel
Follow the install instructions for creating a fresh Laravel app from their documentation.
Install Laravel Sail into your new Laravel app with no additional services, unless you want to get fancy and use MySQL with Statamic (yes, you can do that).
composer require laravel/sail --devphp artisan sail:install --with=none
Starting and Stopping Sail
Before starting Sail, ensure that no other web servers or databases are running on your local computer.
To start all of the Docker containers defined in your site's docker-compose.yml
file, execute the up command:
./vendor/bin/sail up
To start all of the Docker containers in the background, start Sail in "detached" mode:
./vendor/bin/sail up -d
Once the application's containers have been started, your project can be accessed in the browser at: http://localhost.
To stop all of the containers, press Control
+ C
. Or if the containers are running in the background, use the stop command:
./vendor/bin/sail stop
Installing Statamic
At this point you're running Laravel without Statamic in it. Time to change that.
You can now follow the steps to install Statamic into Laravel.
Keep in mind that commands need to be run inside Sail.
- Instead of
php artisan
, runsail artisan
- Instead of
composer require
, runsail composer require
- Instead of
php please
, runsail artisan statamic
Learn more about Laravel Sail
The Laravel Sail docs cover a lot more of what you can do with Sail. Check them out!