Skip to main content
WritingVideosSpeakingCodeAbout

Package

kit

Opinionated Laravel API starter kit: token authentication, standards-compliant HTTP via api-toolbox, and contract-tested OpenAPI docs.

v0.2.330 downloads114 stars

PHPLaravel 13

A Laravel starter kit for token-authenticated APIs, built on the published HTTP standards. Every error is RFC 9457 problem details, creating things takes an Idempotency-Key, lists page through Link headers, webhooks go out as signed CloudEvents, and the OpenAPI spec is checked against the running API on every build. It ships with a production image on Octane and FrankenPHP.

The standards themselves come from api-toolbox. Kit is the application around it, with the conventions already in place and a CI pipeline that fails when something breaks them.

Install

Terminal window
laravel new my-api --using=juststeveking/kit
cd my-api

The installer sets up .env, the key and a migrated SQLite database. Emails are queued, so run a worker beside the API:

Terminal window
php artisan serve
php artisan queue:work

Routes live under http://127.0.0.1:8000/v1/, with no /api prefix, and mail goes to the log until you configure a mailer. Registering a user is a quick check that it all works:

Terminal window
curl -X POST http://127.0.0.1:8000/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"name": "Jane Doe", "email": "jane@example.com", "password": "Password123!", "device_name": "cli"}'

Getting started goes from here to an authenticated request.

What is in it

  • PHP 8.5, Laravel 13, Sanctum, Pest, PHPStan at level 10, Pint with the PER preset, and Rector
  • Invokable controllers, Form Requests, readonly payload objects and plain JSON resources
  • php artisan make:endpoint, which scaffolds an endpoint the way the rest of Kit is built
  • Every error as application/problem+json, typed from the apiguide.dev catalogue, with a detail translated from Accept-Language
  • Idempotency-Key, Deprecation and Sunset, Link header pagination, ETags, request IDs and W3C trace context, and an API catalog at /.well-known/api-catalog
  • Outbound webhooks that consumers subscribe to themselves: CloudEvents, signed with RFC 9421, retried on a published schedule, and recorded attempt by attempt
  • OpenAPI from Scribe attributes, contract tests that compare the spec with real responses, and a legible gate that keeps it readable by agents
  • A Dockerfile for Octane on FrankenPHP, built and booted in CI on every push
  • Laravel Vet auditing every dependency, and a weekly update PR
  • An AGENTS.md that tells coding agents how to build on Kit without undoing it

See it in an application

Flagpole is a feature flag service built on Kit, which applications evaluate with any OpenFeature SDK. Each Kit feature it uses is one a flag service needs: ETags for clients that poll, If-Match so two people cannot overwrite each other’s rules, keys scoped tightly enough to put in a browser. Its first commit is Kit as the installer wrote it, and each commit after that adds one thing, so you can see what building on Kit involves.

Documentation

PageWhat it covers
Getting startedInstalling, running locally, your first requests, where things live
AuthenticationSession tokens, API keys, abilities, verification and password reset
Building endpointsmake:endpoint and each piece it writes
ErrorsProblem details, and raising errors of your own
HTTP standardsIdempotency, pagination, ETags, deprecation, request IDs, media types
LocalizationAccept-Language, translated errors, adding a language
WebhooksWhat subscribers receive, and adding your own events
API documentationScribe, the OpenAPI spec, contract tests and legible
SecurityTransport, CORS, trusted hosts, rate limits and audit logging
DeploymentThe Docker image, workers, the scheduler and Octane
Quality and CIThe checks, the workflows, and reviewing dependencies with Vet
ConfigurationEvery environment variable Kit adds

License

MIT. See LICENSE.

Share

XLinkedIn

Related

More Packages

All projects →

Same subject

In other formats

All of API Design →