PHPackages                             apiforge/apiforgephp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. apiforge/apiforgephp

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

apiforge/apiforgephp
====================

API observability &amp; intelligence for Laravel/PSR-15 — local-first, privacy-first

3.0.0(2w ago)012↓50%MITPHPPHP &gt;=8.2CI passing

Since Jun 3Pushed 2w agoCompare

[ Source](https://github.com/APIForge-Organisation/sdk-composer)[ Packagist](https://packagist.org/packages/apiforge/apiforgephp)[ RSS](/packages/apiforge-apiforgephp/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (10)Versions (7)Used By (0)

apiforgephp
===========

[](#apiforgephp)

**API observability &amp; intelligence for Laravel — local-first, privacy-first.**

[![Packagist Version](https://camo.githubusercontent.com/885c23f34627ecce1a07fe3ac36584a23358b44ba30fe5a6e5162c77b889f67f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617069666f7267652f617069666f7267657068703f636f6c6f723d303036364646)](https://packagist.org/packages/apiforge/apiforgephp)[![CI](https://camo.githubusercontent.com/fda1c8e08001825d4f2b0b757886aabf7c9c4ba57217dc112295aad3f7da15cd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f415049466f7267652d4f7267616e69736174696f6e2f73646b2d636f6d706f7365722f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/APIForge-Organisation/sdk-composer/actions)[![License: MIT](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![PHP](https://camo.githubusercontent.com/57a4b2b97b530830a27833fee0e4f091c19a05a2936c2e4a1b319d1349ad1f35/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d627269676874677265656e)](https://php.net)

> Track latency, error rates, and behavioral trends of your APIs. Everything stays on your machine.

**→ [Full documentation](https://apiforge-organisation.github.io/docs/)**

---

Install
-------

[](#install)

```
composer require apiforge/apiforgephp
```

> Requires PHP ≥ 8.2 and the `pdo_sqlite` extension (`php8.x-sqlite3` package on Debian/Ubuntu).

Quick start
-----------

[](#quick-start)

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).

Dashboard
---------

[](#dashboard)

In local mode, the dashboard is served automatically at `/_apiforge` on your Laravel app's port — no separate process needed.

```
http://localhost:8000/_apiforge

```

- **Health Score** (0–100) — global API health at a glance
- **Latency percentiles** — P50 / P90 / P99 per route
- **Error rates** — 4xx and 5xx breakdown
- **Automatic insights** — latency anomalies, dead endpoints, release regressions
- **Time series chart** — click any route to see its latency over time

Configuration
-------------

[](#configuration)

Publish the config file (optional):

```
php artisan vendor:publish --tag=apiforge-config
```

Or configure via environment variables:

VariableDefaultDescription`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_…`)Cloud mode
----------

[](#cloud-mode)

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.

Release tracking
----------------

[](#release-tracking)

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.

What you get
------------

[](#what-you-get)

- **Per-route latency** — P50, P90, P99 per endpoint
- **Error rate by route** — 2xx / 3xx / 4xx / 5xx breakdown
- **API Health Score** — a single 0–100 score summarising your API's health
- **Ghost route detection** — requests that match no declared Laravel route
- **Latency anomaly alerts** — Z-score detection against a 7-day baseline
- **Dead endpoint detection** — routes with no traffic for 21+ days
- **Release regression analysis** — automatic P90 comparison per deploy
- **Progressive drift detection** — slow latency increases over weeks
- **Untracked route detection** — declared routes that never received traffic
- **Inflight concurrency tracking** — approximate `inflight_avg` and `inflight_max` per route

Graceful shutdown
-----------------

[](#graceful-shutdown)

The 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.

Known limitations
-----------------

[](#known-limitations)

LimitationDetail**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.Privacy by design
-----------------

[](#privacy-by-design)

- Request and response bodies are never read
- No PII captured — only route patterns, HTTP methods, status codes, and timing
- Route parameters are normalised (`/users/42` → `/users/:id`, UUIDs → `/:uuid`)
- SQLite database stays entirely on your server in local mode
- Sampling rate can be set below 1.0 to reduce storage footprint

Requirements
------------

[](#requirements)

- PHP ≥ 8.2
- Laravel ≥ 10.0
- `ext-pdo_sqlite` — install with `apt install php8.x-sqlite3` if not present

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance97

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

5

Last Release

16d ago

Major Versions

1.1.0 → 2.0.02026-06-04

2.0.1 → 3.0.02026-07-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/f23dc09e808fe9c62846b571d0913fa0c784342b4b1e118b47810fcc09905ddd?d=identicon)[Fabien83560](/maintainers/Fabien83560)

---

Top Contributors

[![Fabien83560](https://avatars.githubusercontent.com/u/105244670?v=4)](https://github.com/Fabien83560 "Fabien83560 (35 commits)")

---

Tags

middlewareapilaravelmonitoringperformanceMetricsanalyticsobservabilitylocal-first

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/apiforge-apiforgephp/health.svg)

```
[![Health](https://phpackages.com/badges/apiforge-apiforgephp/health.svg)](https://phpackages.com/packages/apiforge-apiforgephp)
```

###  Alternatives

[cboxdk/laravel-queue-metrics

Production-ready Laravel queue monitoring with metrics, analytics, and insights

114.2k7](/packages/cboxdk-laravel-queue-metrics)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
