Laravel Sail is a light-weight properties interface for interacting with Laravel's default Docker development environment.
Laravel Sail is a light-weight properties interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience.
At its heart, Sail is the
docker-compose.yml file and the
sail 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 code
Laravel Sail is supported on macOS, Linux, and Windows
Docker is a tool for running applications and services in small, light-weight
containers which do not interfere with your local computer's installed software or configuration.
This means you don't have to worry about configuring or setting up complicated development tools such as web servers and databases on your personal computer.
To get started, you only need to install Docker.
Laravel Sail is automatically installed with all new Laravel applications so you may start using it immediately. To learn how to create a new Laravel application, please consult Laravel's installation documentation for your operating system.
Sail using the
Composer package manager. Of course, these steps assume that your existing local development environment allows you to install Composer dependencies:
composer require laravel/sail --dev
sail:install Artisan command. This command will publish Sail's
docker-compose.yml file to the root of your application:
php artisan sail:install
vendor/bin/sail script that is included with all new Laravel applications:
vendor/bin/sail to execute Sail commands, you may wish to configure a
Bash alias that allows you to execute Sail's commands more easily:
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
sail. The remainder of this documentation's examples will assume that you have configured this alias:
docker-compose.yml file defines a variety of Docker containers that work together to help you build Laravel applications. Each of these containers is an entry within the services configuration of your
docker-compose.yml file. The
laravel.test container is the primary application container that will be serving your application.
Before starting Sail, you should ensure that no other web servers(xampp/wamp) or databases are running on your local computer. To start all of the Docker containers defined in your application's
docker-compose.yml file, you should execute the up command:
To start all of the Docker containers in the background, you may start Sail in
sail up -d
Once the application's containers have been started, you may access the project in your web browser at: http://localhost.
To stop all of the containers, you may simply press
Control + C to stop the container's execution. Or, if the containers are running in the background, you may use the stop command:
sail artisan migrate
sail artisan migrate:fresh
sail artisan db:seed
CRUD app with docker & sail👍🏻
docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
composer install --ignore-platform-reqs
.env.example file at root folder and rename it to
.env by running below command Or also can manually rename it:
ren .env.example .env
mv .env.example .env
We assume that you have configured this alias
sail up -d
sail artisan key:generate
dev scripts, all of your application's
sail yarn build
sail yarn dev
Pages, SCSS and
sail npm run watch-poll
And, All set!!