Local development with Laravel Sail

Published

Updated

⛵

Sail away.

Laravel Sail is Laravel's Docker setup for local development. It is a docker-compose.yml file and a sail command line script that live inside the project.

Laravel Sail runs a Laravel project in Docker containers, one isolated environment per project. It needs a Docker provider such as Docker Desktop.

Installation

To add Sail to an existing project:

composer require laravel/sail --dev
php artisan sail:install
bash

Usage

# Start the containers
./vendor/bin/sail up

# Run Artisan commands
./vendor/bin/sail artisan migrate

# Run Composer
./vendor/bin/sail composer require guzzlehttp/guzzle
bash

A shell alias shortens ./vendor/bin/sail to sail.

Sail, Valet and Herd

Valet and Herd run PHP on the host system. Sail runs everything in containers: nothing gets installed on the computer itself, but Docker uses more memory.

Working with fortrabbit

Sail is for local development only. A deployment to fortrabbit sends the code, not the containers; the environment provides PHP and MySQL. Match the PHP version in docker-compose.yml to the PHP version of the environment.

Frequently asked

What is Laravel Sail?

Laravel Sail is a command line interface for the Docker setup of a Laravel project. It starts PHP, MySQL and other services in containers, so nothing but Docker needs to be installed on the computer.

#

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗