PHPackages                             mahbubhelal/record-api-request - 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. mahbubhelal/record-api-request

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

mahbubhelal/record-api-request
==============================

A Laravel package for recording API requests via middleware with a built-in dashboard endpoint.

v1.0.0(3mo ago)011MITPHPPHP ^8.3

Since Apr 9Pushed 3mo agoCompare

[ Source](https://github.com/mahbubhelal/record-api-request)[ Packagist](https://packagist.org/packages/mahbubhelal/record-api-request)[ RSS](/packages/mahbubhelal-record-api-request/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (12)Versions (2)Used By (0)

record-api-request
==================

[](#record-api-request)

A Laravel package for recording API requests via middleware, with a built-in dashboard endpoint for browsing them.

Each request that passes through the middleware is persisted with its timestamp (to millisecond precision), path, status, response time, response length, IP, authenticated user, query string, and user agent. A paginated, sortable listing endpoint is registered at `GET /api-requests`.

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

[](#requirements)

- PHP `^8.3`
- Laravel `^11.0 || ^12.0`
- The dashboard endpoint defaults to being protected by [Laravel Sanctum](https://laravel.com/docs/sanctum) with an `access-api-requests` token ability. The middleware stack is configurable — see [Configuring the dashboard endpoint](#configuring-the-dashboard-endpoint) if you use a different auth driver.

Installation
------------

[](#installation)

```
composer require mahbubhelal/record-api-request
```

Publish and run the migration:

```
php artisan vendor:publish --tag=record-api-request-migrations
php artisan migrate
```

Optionally publish the config file if you want to customise the dashboard route path or middleware stack:

```
php artisan vendor:publish --tag=record-api-request-config
```

Recording requests
------------------

[](#recording-requests)

Apply the `RecordApiRequest` middleware to the routes you want to track. The middleware records the request during Laravel's `terminate` phase, so it does not add latency to the response.

For example, to track every route in your `api` group, add it to `bootstrap/app.php`:

```
use Mahbub\RecordApiRequest\Http\Middleware\RecordApiRequest;

->withMiddleware(function (Middleware $middleware) {
    $middleware->api(append: [
        RecordApiRequest::class,
    ]);
})
```

Or attach it to individual routes:

```
Route::middleware(RecordApiRequest::class)->get('/orders', ...);
```

Viewing recorded requests
-------------------------

[](#viewing-recorded-requests)

The package registers `GET /api-requests` behind `auth:sanctum` and `ability:access-api-requests` by default. Issue a Sanctum token with that ability to the users who should be allowed to view the dashboard:

```
$token = $user->createToken('dashboard', ['access-api-requests']);
```

### Configuring the dashboard endpoint

[](#configuring-the-dashboard-endpoint)

The middleware stack and route path are driven by `config/record-api-request.php`:

```
return [
    'route' => [
        'path' => 'api-requests',
        'middleware' => [
            'api',
            'auth:sanctum',
            'ability:access-api-requests',
        ],
    ],
];
```

Replace `middleware` with whatever stack fits your app (e.g. `['web', 'auth']` for a session-authenticated dashboard, or a custom gate middleware) and set `path` if you want to mount the endpoint somewhere other than `/api-requests`.

### Query parameters

[](#query-parameters)

ParameterDescription`sort`Sort field. Prefix with `-` for descending. Allowed: `time`, `status`, `responseTime`, `responseLength`. Defaults to `-time`.`perPage`Page size. Defaults to `15`.`page`Page number. Defaults to `1`.### Response shape

[](#response-shape)

```
{
    "data": {
        "amountPerPage": 15,
        "page": 1,
        "totalAmount": 120,
        "totalPages": 8,
        "requests": [
            {
                "time": "2026-04-09 14:23:11.482",
                "status": 200,
                "responeTime": "42ms",
                "responseLength": "1.2kB",
                "ip": "203.0.113.7",
                "user": "Ada Lovelace (ada@example.com)",
                "url": "https://example.test/api/orders?status=active",
                "userAgent": "Mozilla/5.0 ..."
            }
        ]
    }
}
```

Development
-----------

[](#development)

The package ships with a Docker-based dev environment. Common commands:

```
./dc buildup          # build and start the containers
./dc pest             # run the test suite
./dc pest --coverage  # run tests with coverage
./dc phpstan          # run static analysis
./dc pint             # run the formatter
./dc rector           # run automated refactors
```

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance80

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7133d7d156fc25a67474a27228a17475407b62ed2308a6e51c8f3a35407fbada?d=identicon)[mahbub\_helal](/maintainers/mahbub_helal)

---

Top Contributors

[![mahbubhelal](https://avatars.githubusercontent.com/u/7233764?v=4)](https://github.com/mahbubhelal "mahbubhelal (1 commits)")

---

Tags

requestmiddlewareapilaravelloggingmonitoring

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mahbubhelal-record-api-request/health.svg)

```
[![Health](https://phpackages.com/badges/mahbubhelal-record-api-request/health.svg)](https://phpackages.com/packages/mahbubhelal-record-api-request)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k30.2M151](/packages/laravel-cashier)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k21](/packages/fleetbase-core-api)

PHPackages © 2026

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