Skip to content

Commit 38bc753

Browse files
authored
Add Laravel Boost support (#184)
* Add Laravel Boost guidelines and skills * Add spin-mcp-wait.sh script for Laravel Boost MCP setup and update documentation - Added spin-mcp-wait.sh to composer.json and package.json for improved MCP server startup. - Updated core.blade.php and SKILL.md to include instructions for configuring Laravel Boost with the new script. - Emphasized the correct usage of spin-mcp-wait.sh to avoid misuse during command execution.
1 parent 424484a commit 38bc753

10 files changed

Lines changed: 1576 additions & 2 deletions

File tree

bin/spin-mcp-wait.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
#
3+
# MCP stdio bridge for Spin + Laravel Boost.
4+
#
5+
# Solves two problems when running Boost's MCP server inside Docker:
6+
# 1. Cursor/IDEs start MCP servers on launch — Docker may not be ready yet.
7+
# This script retries until the container is available.
8+
# 2. Docker outputs startup noise (ANSI codes, container messages) that
9+
# corrupts the JSON-RPC stdio protocol. This script filters stdout to
10+
# pass only JSON-RPC messages.
11+
#
12+
# Usage (in .env):
13+
# BOOST_PHP_EXECUTABLE_PATH="./vendor/bin/spin-mcp-wait.sh ./vendor/bin/spin run -T php php"
14+
#
15+
# This script is ONLY for MCP server startup. For all other commands, use
16+
# spin directly: spin run php composer install
17+
18+
set -euo pipefail
19+
20+
is_mcp=0
21+
for arg in "$@"; do
22+
[ "$arg" = "boost:mcp" ] && is_mcp=1 && break
23+
done
24+
25+
if [ "$is_mcp" -eq 0 ]; then
26+
echo "Error: spin-mcp-wait.sh is only for starting the MCP server." >&2
27+
echo "Use 'spin' directly instead. Example: spin run php composer install" >&2
28+
exit 1
29+
fi
30+
31+
MAX_RETRIES=${SPIN_MCP_MAX_RETRIES:-60}
32+
SLEEP_SECONDS=${SPIN_MCP_RETRY_INTERVAL:-5}
33+
attempt=0
34+
35+
while [ $attempt -lt $MAX_RETRIES ]; do
36+
"$@" 2>/dev/null | grep --line-buffered '^{'
37+
exit_code="${PIPESTATUS[0]}"
38+
39+
[ "$exit_code" -eq 0 ] && exit 0
40+
[ "$exit_code" -gt 128 ] && exit "$exit_code"
41+
42+
attempt=$((attempt + 1))
43+
echo "spin-mcp-wait: attempt $attempt/$MAX_RETRIES failed (exit $exit_code), retrying in ${SLEEP_SECONDS}s..." >&2
44+
sleep "$SLEEP_SECONDS"
45+
done
46+
47+
echo "spin-mcp-wait: gave up after $MAX_RETRIES attempts." >&2
48+
echo "spin-mcp-wait: Is Docker Desktop running?" >&2
49+
exit 1

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "serversideup/spin",
33
"description": "Replicate your production environment locally using Docker. Just run \"spin up\". It's really that easy.",
44
"bin": [
5-
"bin/spin"
5+
"bin/spin",
6+
"bin/spin-mcp-wait.sh"
67
],
78
"authors": [
89
{

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"homepage": "https://github.com/serversideup/spin#readme",
1515
"bin": {
16-
"spin": "./bin/spin"
16+
"spin": "./bin/spin",
17+
"spin-mcp-wait.sh": "./bin/spin-mcp-wait.sh"
1718
}
1819
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

Comments
 (0)