Search by

fusion-stack / starter

neondigital

An API-first Laravel starter kit with Fusion Stack: JSON:API, API keys and Sanctum tokens, idempotency, HTTP caching, versioning and an API reference.

Package info

github.com/fusion-stack/starter

Homepage

Issues

Type:project

pkg:composer/fusion-stack/starter

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.1 2026-12-01 13:37 UTC

This package is auto-updated.

Last update: 2026-12-01 14:19:14 UTC


README

An API-first Laravel app with Fusion Stack set up: 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.

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

Then open http://localhost:8000/docs.

While it creates the project, the installer asks whether to include two optional parts, both off by default:

  • The MCP server (fusion-stack/mcp), so AI clients such as Claude can use the API with the same keys and scopes. The Teams endpoints become MCP tools.
  • Webhooks scaffolding: creating a team sends team.created to subscribed endpoints, signed and in each endpoint's pinned version.

The installer removes itself once you have answered. Without a terminal, such as in CI or under an AI agent, it cannot ask, so give the answers as options instead: php artisan starter:install --mcp --webhooks, or --defaults for neither.

npm create @fusion-stack@latest asks the same questions and also offers a Laravel API with a Nuxt frontend in one repository, the full stack starter, which creates this kit as its api/.

The kit is thin. 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.

Try it

Create an API key with the scopes it needs:

php artisan api:key:create "Local" --scope=teams:read --scope=teams:write
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, signs in as a user instead and gets a Sanctum token. The seeded user is test@example.com with the password password:

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 where

Path What it is
routes/api.php The API's routes, under /v1 in the fusion-stack middleware group. There are no web routes or views.
app/Http/Controllers/TeamController.php The example resource. Each action has an #[Endpoint] for the docs and a #[RequiresScope].
app/Http/Queries/TeamQuery.php What clients may ask for: filters, sorts, fieldsets and pagination. Anything else is a 400.
app/Http/Resources/TeamResource.php The 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.php POST /v1/tokens: signs a user in and returns a Sanctum token.
app/Api/ErrorCode.php This API's own error codes, such as invalid_credentials.
app/Api/Versions/RenameTierToPlan.php An example version change, for when versioning is on.
config/api.php Fusion Stack's configuration.
openapi.json The 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(...).

php artisan list api shows Fusion Stack's commands.

Commands

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. To use the client in a frontend, see the client project setup guide.

Authentication

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

  • API keys (api_key, built in) 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, then add it to api.auth.guards. Fusion Stack reads its scopes, pinned version and rate limit tier from the attributes in api.auth.attributes, such as Firebase custom claims:

// AppServiceProvider::boot(), with kreait/laravel-firebase
Auth::viaRequest('firebase', function (Request $request): ?GenericUser {
    $token = $request->bearerToken();

    if ($token === null) {
        return null;
    }

    $claims = app(\Kreait\Firebase\Contract\Auth::class)->verifyIdToken($token)->claims()->all();

    return new GenericUser(['id' => $claims['sub'], ...$claims]);
});
// config/auth.php
'guards' => ['firebase' => ['driver' => 'firebase']],

// config/api.php
'auth' => [
    'guards' => ['api_key', 'firebase'],
    'attributes' => ['scopes' => 'api_scopes', ...],
],

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: 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. config/api.php shows how, and app/Api/Versions/RenameTierToPlan.php shows what a change looks like. Scaffold your own with php artisan api:version:make.

Octane

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

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

License

MIT.