Laravel Sail: spinning up the local environment with Docker
Today I was studying how to spin up a Laravel project using Sail.
Early on, I had trouble understanding how to prepare the local environment to run a Laravel application. It was common to need PHP, Composer, a database and other dependencies installed directly on the machine, and that made the process a bit confusing.
At first I thought I needed to configure everything manually on my computer to get the project running. But then I started to understand that Laravel Sail used Docker to create that environment in a more standardized way.
I found it interesting to realize that Sail helps avoid that difference in environments between machines. Instead of each person installing PHP, MySQL, Redis and other tools manually, the project can bring those services up in containers.
After creating or cloning a Laravel project with Sail already configured, I could bring the environment up with:
./vendor/bin/sail up
Or, if I wanted to run it in the background:
./vendor/bin/sail up -d
From there, the Laravel application would be available locally, without me having to install everything directly on my machine.
My initial impression is that Laravel Sail makes things much easier for someone who is starting out, mainly because it reduces the pain of setting up an environment. At the same time, I realized that understanding the basics of Docker helps a lot to avoid treating Sail as a "magic box".