Skip to content

Starter kit ​

The starter kit, fusion-stack/starter, creates a new API-only Laravel app with Fusion Stack already set up. It includes JSON:API responses, API keys and Sanctum tokens with scopes, rate limits, idempotency, HTTP caching, date-based versioning when you need it, and an API reference at /docs. It has no views or Vite: routes/api.php is the entry point, and any client can call it, as Calling the API shows.

The kit is thin. Kits are copied once and never update, so everything it does comes from the fusion-stack/laravel package, which you update with Composer. The kit itself is only configuration and one example resource, Teams, for you to copy and then delete.

You need PHP 8.4+ and Composer 2. Already have a Laravel app? Add Fusion Stack to it instead.

Create an app ​

sh
laravel new my-api --using=fusion-stack/starter
cd my-api
php artisan serve

http://localhost:8000/docs is the API reference. While it creates the app, the installer asks two questions:

QuestionDefault
Include the MCP server?No
Include webhooks scaffolding?No

The MCP server lets AI clients such as Claude use the API, with the same keys and scopes. Webhooks scaffolding sends team.created to subscribed endpoints when a team is created.

Without a terminal, such as in CI or under an AI agent, the installer cannot ask. It stays in place and tells you to run it with the answers as options:

sh
php artisan starter:install --mcp --webhooks   # or --defaults for neither

It removes itself once it has run. Then commit everything: from here on it is your code.

With npm instead of the Laravel installer

npm create @fusion-stack creates the same app, and is also how you get the Nuxt variant:

sh
npm create @fusion-stack@latest my-api -- --api
npm create @fusion-stack@latest my-api -- --api --yes   # the defaults, without asking

Try it ​

Opening the app's root URL shows where things are:

json
{ "name": "My API", "docs": "http://localhost:8000/docs", "openapi": "http://localhost:8000/docs/openapi.json" }

Create an API key with the scopes it needs, then call the Teams endpoints:

sh
php artisan api:key:create "Local" --scope=teams:read --scope=teams:write
sh
curl localhost:8000/v1/teams -H "Authorization: Bearer fs_live_…"
curl -g "localhost:8000/v1/teams?filter[plan][in]=pro,enterprise&sort=name&page[size]=5" -H "Authorization: Bearer fs_live_…"
curl -X POST localhost:8000/v1/teams -H "Authorization: Bearer fs_live_…" -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/vnd.api+json" -d '{"data":{"type":"teams","attributes":{"name":"Acme"}}}'

A first-party app, such as a mobile app or your own frontend, signs in as a user instead and gets a Sanctum token. The kit seeds test@example.com with the password password:

sh
curl -X POST localhost:8000/v1/tokens -H "Content-Type: application/vnd.api+json" \
  -d '{"data":{"type":"tokens","attributes":{"email":"test@example.com","password":"password","name":"cli"}}}'

What's in the app ​

PathWhat it is
routes/api.phpThe API's routes, under /v1 in the fusion-stack middleware group, and the root route above. There are no web routes or views.
app/Http/Controllers/TeamController.phpThe example resource. Each action has an #[Endpoint] for the docs and a #[RequiresScope].
app/Http/Queries/TeamQuery.phpWhat clients may ask for: filters, sorts, fieldsets and pagination. Anything else is a 400.
app/Http/Resources/TeamResource.phpThe JSON:API resource, with #[Describe] field descriptions for the docs.
app/Http/Requests/Form requests. Their rules become the request body schema in the docs.
app/Http/Controllers/TokenController.phpPOST /v1/tokens: signs a user in and returns a Sanctum token.
app/Api/ErrorCode.phpThe API's own error codes, such as invalid_credentials.
app/Api/Versions/RenameTierToPlan.phpAn example version change, for when versioning is on.
config/api.phpFusion Stack's configuration.
openapi.jsonThe API's contract, generated from the code. CI checks it is up to date.
tests/Pest tests using the package's helpers: $this->api()->withKey($key)->getJson(...).

With the MCP server, the Teams endpoints are also MCP tools at /mcp, and tests/Feature/McpTest.php covers them. With webhooks, app/Webhooks/TeamCreated.php is sent when a team is created, and tests/Feature/WebhookTest.php covers it.

php artisan list api shows Fusion Stack's commands.

Checks and CI ​

sh
composer check   # Pint, PHPStan and Pest
composer api     # check every endpoint is described, then write openapi.json

.github/workflows/tests.yml runs both, checks openapi.json is committed and up to date, and generates the TypeScript client as a build artifact.

Authentication ​

Requests are authenticated by the guards in api.auth.guards, tried in order:

  • API keys (api_key) for servers and integrations. Keys have scopes, can be pinned to a version and are stored only as a hash. Manage them with api:key:create and api:key:pin.
  • Sanctum tokens (sanctum) for your own apps. A token's abilities are its scopes.

To authenticate with something else, such as Firebase, register a guard that returns the signed-in user and add it to api.auth.guards. Fusion Stack reads the user's scopes, pinned version and rate limit tier from the attributes named in api.auth.attributes, such as Firebase custom claims. The kit's README.md has a complete Firebase example. For an identity that needs more than reading attributes, implement FusionStack\Laravel\Auth\ClientResolver and list it in api.auth.resolvers.

Versioning ​

Versioning is off in the kit: every client gets the current API and sends no Api-Version header. Turn it on when you make your first breaking change after clients depend on the API:

php
// config/api.php
'versions' => [
    'enabled' => true,
    'latest' => '2027-01-15.atlas',
    'changes' => [
        '2027-01-15.atlas' => [\App\Api\Versions\RenameTierToPlan::class],
    ],
],

Set default to the version clients without an Api-Version header should get, so existing clients keep their behaviour. app/Api/Versions/RenameTierToPlan.php shows what a change looks like, and tests/Unit/RenameTierToPlanTest.php how to test one. Scaffold your own with php artisan api:version:make.

Octane ​

The kit includes Octane's configuration. Install a server and run it:

sh
php artisan octane:install --server=frankenphp
php artisan octane:start

Adding a Nuxt frontend ​

To build a Nuxt app alongside the API, use the full stack variant, fusion-stack/starter-nuxt. It is one repository with the same Laravel app in api/, a Nuxt app in web/ and the typed client generated from the API in packages/client/. It needs Node 22+ as well.

sh
npm create @fusion-stack@latest my-app -- --nuxt
cd my-app
npm run dev   # the API on http://localhost:8000, the web app on http://localhost:3000

Sign in to the web app as test@example.com with the password password. Everything above applies to api/.

The web app only knows the API through packages/client, which is generated from api/openapi.json. After changing an endpoint, resource, query or form request in api/, run:

sh
npm run api

This checks every endpoint is described, writes api/openapi.json and regenerates packages/client/index.ts. npm run typecheck then shows the places in web/ your change affects. Commit the three together, so a pull request shows an API change and what it means for the frontend in one diff. .github/workflows/ci.yml checks the API, the client and the web app together, and fails when they are out of date.

  • web/nuxt.config.ts sets the API's URL. Server-side rendering calls the API directly; the browser calls /v1 on the web app, which Nuxt proxies to the API, so there is no CORS to set up. In production, set API_URL when you build, such as API_URL=https://api.example.com npm run build: the proxy and server rendering keep the URL the build had.
  • web/app/pages/login.vue posts to /v1/tokens and keeps the Sanctum token in a cookie, which @fusion-stack/nuxt sends with every request. web/app/middleware/auth.global.ts sends signed-out visitors to the sign-in page.
  • web/app/pages/index.vue lists, filters, pages, creates and deletes teams with the generated endpoints.
  • The client sends the API version it was generated from as Api-Version, so responses always match its types.

For any other frontend, such as Next.js, React Native or a mobile app, keep the API-only kit and add a client: Client project setup generates a typed TypeScript one, and Calling the API covers every other language.

Released under the MIT License.