Skip to content

Quickstart: Laravel (PHP) ​

A running Fusion Stack API in five minutes, for readers who know Laravel. Building with Laravel for Rust? Follow the Rust quickstart instead. New to Laravel, or want the whole picture from an empty machine to a deployed app? Follow Build your first API instead.

You need PHP 8.4+ with mbstring, intl, bcmath and pdo_sqlite, Composer 2 and Node 22+.

Create and run an app ​

sh
npm create @fusion-stack@latest my-api -- --api --yes
cd my-api
php artisan serve

This creates an API-only app with the defaults: no MCP server and no webhooks. Leave out --api --yes to be asked instead, including whether you want a Nuxt frontend. The starter kit guide explains each choice.

http://localhost:8000/docs is the API reference, generated from your code.

Make a request ​

In a second terminal, create an API key with the scopes it needs, and ask for the example resource, teams:

sh
php artisan api:key:create "Local" --scope=teams:read --scope=teams:write
export KEY=fs_live_…
curl localhost:8000/v1/teams -H "Authorization: Bearer $KEY"
json
{
  "data": [
    {
      "id": "12",
      "type": "teams",
      "attributes": { "name": "Ferry-Adams", "plan": "enterprise", "created_at": "2026-12-01T08:33:15.000000Z", "updated_at": "2026-12-01T08:33:15.000000Z" }
    }
  ],
  "links": { "first": "http://localhost:8000/v1/teams?page%5Bsize%5D=25", "prev": null, "next": null },
  "meta": { "page": { "size": 25 } }
}

Without the key you get a 401 with a stable code and a request_id, as every error does.

Where to look next ​

The kit's Teams example shows every part of an endpoint. Copy it for your own resources, then delete it:

FileWhat it does
app/Http/Resources/TeamResource.phpWhat clients see, described with #[Describe].
app/Http/Queries/TeamQuery.phpThe filters, sorts and includes clients may use. Anything else is a 400.
app/Http/Requests/StoreTeamRequest.phpWhat clients may send. The rules are also the request schema in the reference.
app/Http/Controllers/TeamController.phpThe endpoints, with #[RequiresScope] and #[Endpoint].
tests/Feature/TeamTest.phpTests with Fusion Stack's helpers: apiKey(), assertApiError() and more.

Run composer check for Pint, PHPStan and the tests, and composer api to check every endpoint is described and write openapi.json.

Released under the MIT License.