ddelosreyes / http-requests-logger-for-laravel
A simple HTTP request logger for Laravel with buffered inserts and support for both relational databases and DynamoDB.
Package info
github.com/delosreyesdan/http-requests-logger-for-laravel
pkg:composer/ddelosreyes/http-requests-logger-for-laravel
Requires
- php: ^8.2
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- pestphp/pest: ^3.8
- pestphp/pest-plugin-laravel: ^3.2
- phpunit/phpunit: ^10.5|^11.5
- rector/rector: ^0.18
Suggests
- ext-redis: Required if you want to use Redis as a buffer backend.
- aws/aws-sdk-php: Required if you want to use DynamoDB as the storage driver.
This package is auto-updated.
Last update: 2026-03-07 18:46:33 UTC
README
๐ง WORK IN PROGRESS.
Yet another HTTP request logger for Laravel โ but built to be fast, buffered, and flexible.
This package logs incoming HTTP requests in batches to your preferred storage:
- โ Database (MySQL, Postgres, SQLite, etc.)
- โ Redis buffer (auto-flushed in batches)
- ๐ง DynamoDB support (coming soon)
โจ Features
- ๐ Buffered logging โ requests are first pushed to Redis for efficiency.
- ๐ Pluggable storage โ store logs in your DB or Redis (configurable).
- โก๏ธ Batch inserts โ reduces DB overhead by inserting multiple logs at once.
- ๐ Configurable batch size & Redis connection.
- ๐งช Pest + Testbench powered test suite with Docker setup.
๐ฅ Installation
Require the package via Composer:
composer require ddelosreyes/http-requests-logger-for-laravel
If auto-discovery is disabled, register the service provider manually:
// config/app.php 'providers' => [ Ddelosreyes\\HttpRequestsLogger\\HttpRequestsLoggerServiceProvider::class, ];
Publish the config and migration:
php artisan vendor:publish --provider="Ddelosreyes\\HttpRequestsLogger\\HttpRequestsLoggerServiceProvider" --tag=config php artisan vendor:publish --provider="Ddelosreyes\\HttpRequestsLogger\\HttpRequestsLoggerServiceProvider" --tag=migrations php artisan migrate
โ๏ธ Configuration
In the config/http-requests-logger.php
return [ 'storage' => env('HTTP_REQUEST_LOGGER_STORAGE', 'database'), 'batch_size' => env('HTTP_REQUEST_LOGGER_BATCH_SIZE', 500), 'table' => env('HTTP_REQUEST_LOGGER_TABLE', 'http_request_logs'), 'redis' => [ 'scheme' => env('REDIS_SCHEME', 'tcp'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'port' => env('REDIS_PORT', 6379), 'password' => env('REDIS_PASSWORD', null), 'database' => env('REDIS_DB', 0), 'timeout' => env('REDIS_TIMEOUT', 1.5), ], ];
In your dotenv
HTTP_REQUEST_LOGGER_STORAGE=database HTTP_REQUEST_LOGGER_BATCH_SIZE=500 HTTP_REQUEST_LOGGER_TABLE=http_request_logs REDIS_SCHEME=tcp REDIS_HOST=127.0.0.1 REDIS_PORT=6379 REDIS_PASSWORD=null REDIS_DB=0
๐ How It Works
- Every incoming request is captured (method, URL, IP, user agent, headers, body)
- Log payload is pushed to Redis (list)
- Once the buffer reaches
batch_size, logs are flushed into SQL in a single insert - Flush can also be triggered manually
๐ Logged Data
[ 'method' => $request->getMethod(), 'url' => $request->getRequestUri(), 'ip' => $request->getClientIp(), 'user_agent' => $request->getUserAgent(), 'headers' => json_encode($request->headers->all()), 'body' => json_encode($request->all()), ]
Usage
Option A: Middleware
// app/Http/Kernel.php protected $middleware = [ \Ddelosreyes\HttpRequestsLogger\Http\Middleware\LogHttpRequest::class, ];
Option B: Manually log in controller/job
use Ddelosreyes\HttpRequestsLogger\Actions\RequestLogBufferAction; RequestLogBufferAction::add($request);
๐งช Testing
This package is built with PestPHP + Orchestra Testbench.
Run tests locally with Docker:
make build
make test