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.
Composerpackage manager. Of course, these steps assume that your existing local development environment allows you to install Composer dependencies:
composer require laravel/sail --dev
sail:installArtisan command. This command will publish Sail's
docker-compose.ymlfile to the root of your application:
php artisan sail:install
vendor/bin/sailscript that is included with all new Laravel applications:
vendor/bin/sailto execute Sail commands, you may wish to configure a
Bash aliasthat 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:
docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer install --ignore-platform-reqs
.env.examplefile at root folder and rename it to
.envby 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
devscripts, all of your application's
sail yarn dev
sail npm run watch-poll
And, All set!!