This package is abandoned and no longer maintained. The author suggests using the mohamedhekal/apiforge package instead.

Laravel API kit: version negotiation, JSON envelopes, consistent error rendering, and route helpers

Maintainers

Package info

github.com/mohamedhekal/apiforge

pkg:composer/mohamedmohamedhekal/apiforge

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-07-16 14:23 UTC

This package is auto-updated.

Last update: 2026-07-16 14:40:18 UTC


README

CI License: MIT PHP Laravel

Search terms: laravel, api, versioning, json, errors, rest, php, laravel-package, rest-api, api-errors, json-api.

Laravel API kit: version negotiation, JSON success/error envelopes, exception rendering, and Route::apiVersion() helpers.

Installation

composer require mohamedhekal/apiforge
php artisan vendor:publish --tag=apiforge-config

Versioned routes

use Hekal\ApiForge\Facades\ApiForge;
use Illuminate\Support\Facades\Route;

Route::apiVersion('v1', function () {
    Route::get('/orders', fn () => ApiForge::ok(['orders' => []]));
});
// GET /api/v1/orders

Middleware aliases: apiforge.version, apiforge.json.

Version can also come from X-API-Version or Accept: application/vnd.apiforge.v1+json.

Envelopes

{
  "data": { "id": 1 },
  "error": null,
  "meta": { "version": "v1", "request_id": "..." }
}
ApiForge::fail('Out of stock', 'out_of_stock', 409, ['sku' => 'A1']);
throw new \Hekal\ApiForge\Exceptions\ApiException('Nope', 'conflict', 409);

Validation / auth / 404 exceptions under API routes render into the same shape.

Composition

Pair with mohamedhekal/oncegate for Idempotency-Key on mutating routes. Rate limiting stays Laravel’s throttle middleware.

Limitations (v0.1)

  • No OpenAPI generator yet
  • Does not replace Form Requests or API Resources—use them inside controllers as usual
  • Unsupported requested versions fall back to default (not 406)

Testing

composer install && composer test

License

MIT