- How do I install Laravel Sail for a new Laravel project?
- Use the `--sail` flag with Laravel’s installer: `laravel new project-name --sail`. This auto-configures Docker and Sail’s `compose.yaml` for you. For existing projects, run `composer require laravel/sail --dev` and follow the setup instructions in the [official docs](https://laravel.com/docs/sail).
- Does Laravel Sail work with Laravel 9 or older versions?
- Sail 2.x is optimized for Laravel 10/11/12/13 and PHP 8.5+. For Laravel 9 or older, use Sail 1.x or manually override Docker configurations. Check the [version compatibility table](https://laravel.com/docs/sail#version-compatibility) for details.
- Can I use Sail with Windows without WSL2?
- No, Sail requires WSL2 on Windows for full compatibility. Without WSL2, you’ll face performance issues and potential Docker networking problems. Ensure WSL2 is enabled in Windows settings and Docker Desktop is configured to use it.
- How do I add custom services like Elasticsearch or Kafka to Sail?
- Extend Sail’s `compose.yaml` by adding your service under the `services` section. For example, add Elasticsearch with `image: docker.elastic.co/elasticsearch/elasticsearch:8.12.0` and define ports/volumes. Sail’s stubs make this straightforward—see the [custom services docs](https://laravel.com/docs/sail#adding-custom-services).
- Is Laravel Sail suitable for production environments?
- No, Sail is designed for local development only. For production, use Laravel Forge, Vapor, or traditional server setups. Sail’s Docker configurations are optimized for convenience, not scalability or security hardening.
- How do I configure Sail to work with GitHub Actions or CI/CD pipelines?
- Use `SAIL_DOCKER_BINARY=podman` for Podman support in CI. Cache Docker layers with `actions/cache` to speed up builds. Sail’s `.github/workflows/sail.yml` example in the [docs](https://laravel.com/docs/sail#continuous-integration) covers common CI setups like GitHub Actions.
- Why does Sail use `compose.yaml` instead of `docker-compose.yml`?
- Sail adopts the newer `compose.yaml` format (Compose Specification v1.4+) for better tooling support and future-proofing. If migrating from `docker-compose.yml`, run `sail build --no-cache` to regenerate containers. The format is backward-compatible with Docker Compose v2+.
- How do I debug Sail’s Docker networking issues (e.g., Laravel app not accessible)?
- Check if ports are exposed in `compose.yaml` (e.g., `80:8080`). Use `sail ps` to verify containers are running, and `sail logs` to inspect errors. For Laravel-specific issues, ensure `.env` variables like `APP_URL` match your Docker host (e.g., `http://localhost`).
- Can I use Sail with PHP 8.1 or older versions?
- Sail 2.x defaults to PHP 8.5, but you can override it by modifying the `services.laravel` section in `compose.yaml`. For PHP 8.1, specify `image: laravelsail/php81-app:latest` and adjust extensions. Note: Some Laravel features may require newer PHP versions.
- What are the alternatives to Laravel Sail for Docker-based Laravel development?
- Alternatives include **Laravel Vapor** (serverless), **DDEV** (multi-language support), or **Laradock** (customizable but complex). Sail stands out for its Laravel-specific optimizations, minimal setup, and official Laravel support. Compare options based on your need for simplicity vs. flexibility.