API observability & intelligence for Laravel/PSR-15 — local-first, privacy-first
apiforge/apiforgephp is a Laravel package for api observability & intelligence for laravel/psr-15 — local-first, privacy-first.
It currently has 0 GitHub stars and 12 downloads on Packagist (latest version 3.0.0).
Install it with composer require apiforge/apiforgephp.
Discover more Laravel packages by apiforge
or browse all Laravel packages to compare alternatives.
Last updated
API observability & intelligence for Laravel — local-first, privacy-first.
Track latency, error rates, and behavioral trends of your APIs. Everything stays on your machine.
composer require apiforge/apiforgephp
Requires PHP ≥ 8.2 and the
pdo_sqliteextension (php8.x-sqlite3package on Debian/Ubuntu).
The service provider is auto-discovered by Laravel. Register the middleware in your bootstrap/app.php (Laravel 11+) or app/Http/Kernel.php (Laravel 10):
// Laravel 11+ — bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->append(\ApiForge\Laravel\ApiForgeMiddleware::class);
})
// Laravel 10 — app/Http/Kernel.php
protected $middleware = [
// ...
\ApiForge\Laravel\ApiForgeMiddleware::class,
];
That's it. The local dashboard is now live at http://localhost:8000/_apiforge (adjust the port to match your Laravel app).
In local mode, the dashboard is served automatically at /_apiforge on your Laravel app's port — no separate process needed.
http://localhost:8000/_apiforge
Publish the config file (optional):
php artisan vendor:publish --tag=apiforge-config
Or configure via environment variables:
| Variable | Default | Description |
|-----------------------------|---------------------|---------------------------------------------------|
| APIFORGE_ENV | APP_ENV | Environment label (production, staging…) |
| APIFORGE_RELEASE | APP_VERSION | Release/version tag for regression tracking |
| APIFORGE_SERVICE | APP_NAME | Service name |
| APIFORGE_SAMPLING | 1.0 | Sample rate 0.0–1.0 |
| APIFORGE_DASHBOARD | true | Enable/disable the local dashboard routes |
| APIFORGE_DASHBOARD_PREFIX | _apiforge | URL prefix for the local dashboard |
| APIFORGE_CLOUD_URL | — | Cloud mode: SaaS API base URL |
| APIFORGE_API_KEY | — | Cloud mode: project API key (af_…) |
Send metrics to the APIForge SaaS platform instead of storing them locally:
APIFORGE_CLOUD_URL=https://api.apiforge.fr
APIFORGE_API_KEY=af_your_project_key
// bootstrap/app.php — same middleware registration, no code change needed
->withMiddleware(function (Middleware $middleware) {
$middleware->append(\ApiForge\Laravel\ApiForgeMiddleware::class);
})
In cloud mode, events are buffered to a local temp file and flushed to the SaaS ingest API every 60 seconds. The local dashboard is disabled automatically.
Set the release tag to enable before/after deployment comparison:
APIFORGE_RELEASE=v1.4.0
Or dynamically in AppServiceProvider:
config(['apiforge.release' => config('app.version')]);
When a new release is detected, APIForge compares P90 latency before and after and surfaces regressions automatically.
inflight_avg and inflight_max per routeThe middleware flushes automatically at the end of every request. No manual teardown is needed for standard PHP-FPM deployments.
For long-running processes (Laravel Octane, FrankenPHP, Swoole), call shutdown() on application termination if needed — the aggregator is otherwise request-scoped and carries no state between requests.
| Limitation | Detail |
|-----------|--------|
| TTFB = total duration | PHP-FPM sends responses atomically — true Time to First Byte cannot be measured at the middleware layer. lat_ttfb_* values equal lat_*. |
| Approximate inflight count | PHP workers are isolated; the inflight counter is shared via a file lock, which is accurate to the order of magnitude but not microsecond-precise. |
/users/42 → /users/:id, UUIDs → /:uuid)ext-pdo_sqlite — install with apt install php8.x-sqlite3 if not presentMIT — see LICENSE.