Skip to main content

Frontline API for Laravel

Puts a Laravel API behind the Frontline API gateway: publishes its routes, tiers and keys as signed sheets, admits only the requests the gateway signed, and counts what the gateways report.

The gateway stands between the clients and the Laravel application: it checks each request and forwards it signed to the API host, while the application publishes signed sheets to a Redis store that the gateway reads, and the gateway's counts and reports flow back through the store to the application

The Frontline API gateway stands in front of the API host of your Laravel application. Every request passes it first: it checks the caller's key, the key's abilities and limits, and what the route allows, and only then forwards the request to Laravel, signed. The gateway keeps no rules of its own. This package writes them from your application into signed sheets, which the gateways read from a shared Redis store, and it reads back what the gateways count.

The package

Requirements​

  • A Frontline API gateway in front of the API host. The gateway is a separate service and not yet publicly available.
  • PHP 8.4+ (tested on 8.4.27, 8.5.x and 8.6.x) with the sodium extension, which signs the sheets with Ed25519
  • Laravel 13+, as the full laravel/framework rather than separate illuminate/* components
  • Redis 6.2 or later, or Valkey, on a server your gateways reach, for the sheets and the counts
  • A filesystem disk on the object storage your gateways read while the store is down
  • A queue worker, the scheduler, and a default cache store that can hold a lock, such as redis or database

Installation​

composer require pushery/frontline-api-for-laravel

The service provider is registered automatically through package discovery. Then, in this order:

  1. Name the product, its environment, the API host, the store and the disk (Configuration).
  2. Make the signing key, and give its public half to every gateway (The signing key).
  3. Tell the package where your keys and tiers come from (Keys and tiers).
  4. Declare the routes of the API host, and put the gateway's check on them (Declaring routes, The entrance for the gateway).
  5. Run the scheduler and a queue worker, publish in each deployment with php artisan frontline:publish, and check the result with php artisan frontline:status (Publishing the sheets, Status and health).

A new release of the gateway or of this package can move the protocol between them to a new version; Upgrading the protocol gives the order.