|
| 1 | +# Spin — Docker Workflow for Laravel |
| 2 | + |
| 3 | +Spin is a lightweight CLI that wraps Docker Compose (development) and Docker Swarm (production) so you can replicate any environment on any machine. |
| 4 | + |
| 5 | +## Key facts |
| 6 | + |
| 7 | +- Spin follows Docker Compose syntax exactly — `spin up` runs `docker compose up`, `spin run` runs `docker compose run`, etc. |
| 8 | +- Projects use a **Docker Compose overrides** pattern: a base `docker-compose.yml` merged with `docker-compose.dev.yml` (local) or `docker-compose.prod.yml` (production). |
| 9 | +- Laravel projects use `serversideup/php` Docker images (fpm-nginx, fpm-apache, frankenphp, cli). |
| 10 | +- The `.infrastructure/` folder stores configuration files (`conf/`) and gitignored volume data (`volume_data/`). |
| 11 | +- `SPIN_ENV` defaults to `dev`. Running `spin up` uses `docker-compose.yml` + `docker-compose.dev.yml`. |
| 12 | +- In Docker, services connect via container name as hostname (`DB_HOST=mysql`, `REDIS_HOST=redis`), not `localhost`. |
| 13 | + |
| 14 | +## Essential commands |
| 15 | + |
| 16 | +| Command | Purpose | |
| 17 | +|---------|---------| |
| 18 | +| `spin up` | Start development environment (foreground) | |
| 19 | +| `spin up --build` | Start and rebuild containers (recommended default if custom Dockerfile is used) | |
| 20 | +| `spin run <service> <cmd>` | Run a one-off command in a new container | |
| 21 | +| `spin exec <service> <cmd>` | Run a command in a running container | |
| 22 | +| `spin deploy <env>` | Deploy to a provisioned server | |
| 23 | +| `spin provision` | Provision and configure servers | |
| 24 | + |
| 25 | +## When to activate the full skill |
| 26 | + |
| 27 | +For tasks involving Docker Compose configuration, Dockerfile changes, `serversideup/php` image settings, adding Laravel services (databases, queues, Horizon, Reverb), server provisioning, deployment, or troubleshooting containerized environments — activate the **spin-laravel-development** skill. |
| 28 | + |
| 29 | +## Laravel Boost MCP setup |
| 30 | + |
| 31 | +Since Spin runs PHP inside Docker (not on the host), Laravel Boost needs special configuration to start its MCP server. Spin ships `spin-mcp-wait.sh` which retries until Docker is ready and filters stdout for clean JSON-RPC communication. |
| 32 | + |
| 33 | +Add these to your `.env` file: |
| 34 | + |
| 35 | +``` |
| 36 | +BOOST_PHP_EXECUTABLE_PATH="./vendor/bin/spin-mcp-wait.sh ./vendor/bin/spin run -T php php" |
| 37 | +BOOST_COMPOSER_EXECUTABLE_PATH="./vendor/bin/spin run php composer" |
| 38 | +BOOST_NPM_EXECUTABLE_PATH="./vendor/bin/spin run node npm" |
| 39 | +``` |
| 40 | + |
| 41 | +Then run: |
| 42 | + |
| 43 | +``` |
| 44 | +spin run php php artisan boost:install |
| 45 | +``` |
| 46 | + |
| 47 | +**IMPORTANT:** `spin-mcp-wait.sh` is exclusively for MCP server startup. NEVER use it to run commands. Always use `spin run` or `spin exec` for running commands (e.g., `spin run php composer install`). |
| 48 | + |
| 49 | +## Templates |
| 50 | + |
| 51 | +- **Basic** (`spin new laravel`): Free open source template — <https://github.com/serversideup/spin-template-laravel-basic> |
| 52 | +- **Pro** (`spin new laravel-pro`): Premium template with pre-configured services (Horizon, Reverb, databases, Vite, Mailpit, etc.) — <https://getspin.pro> |
| 53 | + |
| 54 | +## Resources |
| 55 | + |
| 56 | +- Spin docs: <https://serversideup.net/open-source/spin/docs> |
| 57 | +- Spin docs (LLM-friendly): <https://serversideup.net/open-source/spin/llms.txt> |
| 58 | +- serversideup/php docs: <https://serversideup.net/open-source/docker-php/docs> |
| 59 | +- serversideup/php docs (LLM-friendly): <https://serversideup.net/open-source/docker-php/llms.txt> |
| 60 | +- serversideup/php full docs (LLM-friendly): <https://serversideup.net/open-source/docker-php/llms-full.txt> |
| 61 | +- serversideup/php environment variable reference: <https://serversideup.net/open-source/docker-php/docs/reference/environment-variable-specification> |
| 62 | +- Spin Pro docs: <https://getspin.pro/docs> |
0 commit comments