laravel/sail
Laravel Sail offers a Docker-powered local development environment for Laravel on macOS, Windows (WSL2), and Linux. With a simple CLI and no extra dependencies beyond Docker, it lets you spin up a full dev stack quickly—even without Docker experience.
Laravel Sail is a first-class fit for PHP/Laravel-based applications, particularly those leveraging Docker for local development. Its pre-configured Docker stack (PHP, MySQL, PostgreSQL, Redis, Mailpit, etc.) aligns seamlessly with Laravel’s ecosystem, eliminating the need for manual Docker orchestration. The package abstracts infrastructure concerns, allowing developers to focus on application logic while maintaining consistency across environments (local, CI/CD, staging).
Key strengths:
.env variable substitution, Artisan commands, and Laravel-specific services (e.g., Horizon, Scout).Potential misfits:
Low-risk for Laravel projects:
composer require laravel/sail and ./vendor/bin/sail up suffices for basic setups.sail artisan migrate or sail queue:work are idiomatic and require no additional tooling.services:
app:
uses: laravel/sail/.github/workflows/services.yml
with:
php-version: '8.2'
Challenges:
.env or docker-compose.override.yml).docker-compose.yml for large applications.| Risk Area | Severity | Mitigation |
|---|---|---|
| Docker dependency | High | Requires Docker Desktop (macOS/Windows) or Docker Engine (Linux). Document fallback options (e.g., Podman via SAIL_DOCKER_BINARY). |
| Resource contention | Medium | Monitor memory/CPU usage; use sail --scale to limit concurrent containers. |
| Service version conflicts | Low | Sail pins versions (e.g., PHP 8.5, PostgreSQL 18) but allows overrides via .env. |
| Networking/port collisions | Medium | Default ports (e.g., 8000, 3306) may conflict; use sail artisan serve --port or .env overrides. |
| Custom service integration | Medium | Extending Sail (e.g., adding Elasticsearch) requires manual docker-compose.yml edits. |
| Debugging complexity | Low | Sail includes XDebug and Laravel Debugbar by default; logs are containerized. |
Critical Questions for TPM:
libpq)?.env.sail overrides)?Sail is optimized for the following stack:
laravel/horizon).Compatibility Notes:
pdo_mysql, bcmath, gd), but custom extensions (e.g., swoole, propro) must be explicitly enabled in Dockerfile stubs.php:apache or php:fpm base images with manual Docker Compose.| Phase | Actions | Tools/Artifacts |
|---|---|---|
| Assessment | Audit current docker-compose.yml/Dockerfile for conflicts with Sail’s defaults. |
sail doctor (hypothetical CLI check). |
| Pilot | Spin up a non-production Laravel service with Sail; validate .env variable substitution. |
sail build --no-cache |
| Incremental Rollout | Migrate one feature branch at a time; use docker-compose.override.yml for customizations. |
GitHub Actions matrix for parallel testing. |
| Full Adoption | Replace local VMs/non-Docker setups; update CI/CD to use Sail images. | sail artisan package:discover (if needed). |
Example Migration Steps:
# Old setup
brew install php mysql
# New setup
composer require laravel/sail --dev
./vendor/bin/sail up
.env:
# Old
DB_HOST=localhost
# New
DB_HOST=sail-mysql
docker-compose.yml:
services:
elasticsearch:
image: docker.elastic.co/elasticsearch:8.12.0
ports:
- "9200:9200"
| Component | Sail Support | Workaround |
|---|---|---|
| Custom PHP extensions | Limited (requires Dockerfile edits) |
Extend laravel/sail:8.2 base image in docker-compose.yml. |
| Non-standard ports | Configurable via .env |
Override SAIL_HTTP_PORT, SAIL_MYSQL_PORT, etc. |
| Windows non-WSL | Unsupported (WSL2 required) | Use Git Bash or Linux VMs; document limitations in onboarding. |
| Kubernetes | No native support | Use docker-compose to kubectl or adopt a multi-stage build with Sail. |
| Airgap environments | Limited (pulls images from Docker Hub) | Pre-pull images or use a private registry mirror. |
docker --version).composer require laravel/sail --dev
cp .env.example .env
sail build --no-cache
sail up
How can I help you explore Laravel packages today?