Installation
Require the package
composer require ark4ne/laravel-api-revisionsThe service provider is auto-discovered.
Publish the configuration
php artisan vendor:publish --tag=revisions-config
This writes config/revisions.php. Every key is described in the
configuration reference.
Declare the revision enum
A revision is a case of a backed enum implementing Revision. order() lists the cases oldest first, and the last
one is the head.
use Ark4ne\ApiRevisions\Revisions\IsRevision;
use Ark4ne\ApiRevisions\Revisions\Meta;
use Ark4ne\ApiRevisions\Revisions\Revision;
enum ApiRevision: string implements Revision
{
use IsRevision;
#[Meta('First published revision', publishedAt: '2025-06-01')]
case Genesis = 'genesis';
public static function order(): array
{
return [self::Genesis];
}
}
Then point the configuration at it:
'enum' => App\Api\ApiRevision::class,
Resolve the revision of each request
Put the revision middleware on your API routes. By default it reads the Api-Revision header.
Route::middleware('revision')->group(function () {
Route::get('/orders/{order}', [OrderController::class, 'show']);
});
Install the test dependency
The schema assertions of the testing helpers validate against JSON Schema:
composer require --dev opis/json-schema
Without an enum
Until enum is set, the library works on one implicit revision, head (Revisions\Unrevisioned). Resources render,
requests validate and every command succeeds, with no history. The middleware resolves nothing and adds no revision
header, so clients see no difference. You can adopt the descriptors first and add revisions later.
Agent skill
The package ships an agent skill: the rules that prevent most mistakes, a reference of every entry point and tested recipes. Link it where your coding agent finds skills, for instance for Claude Code:
mkdir -p .claude/skills
ln -s ../../vendor/ark4ne/laravel-api-revisions/skills/laravel-api-revisions \
.claude/skills/laravel-api-revisions