nhatnathando / laravel-api-replay
Log, store, and replay Laravel API requests.
Package info
github.com/NhatNathanDo/laravel-api-replay
pkg:composer/nhatnathando/laravel-api-replay
v1.0.5
2026-04-03 08:26 UTC
Requires
- php: ^8.1
- illuminate/console: ^9.0|^10.0|^11.0
- illuminate/database: ^9.0|^10.0|^11.0
- illuminate/http: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.0|^10.0
README
Record incoming HTTP requests and responses, store them efficiently, and replay any request accurately for debugging and comparison via a modern Dashboard.
โจ Features
- โก Middleware Recording: Automatically capture Request/Response details.
- ๐ฅ๏ธ Dashboard UI: Visual interface to browse logs and trigger replays (default at
/api-replay). - ๐ก๏ธ Production Safety: Automatic DB Rollback for dry-run replays to keep your data safe.
- ๐ Sensitive Data Masking: Automatically masks passwords and sensitive headers.
- ๐ฏ Accurate Replay: Reconstructs requests using the Laravel HTTP client.
- ๐๏ธ Artisan Command: Still supports
php artisan replay:request {uuid}.
๐ฆ Installation
- Install via composer:
composer require nhatnathando/laravel-api-replay
- Publish configuration, migrations, and UI views:
php artisan vendor:publish --tag="api-replay-config" php artisan vendor:publish --tag="api-replay-migrations" php artisan vendor:publish --tag="api-replay-views"
- Run migrations:
php artisan migrate
๐ Usage
1. Register Middleware
Add the middlewares to your app/Http/Kernel.php (or bootstrap/app.php for Laravel 11+):
protected $middlewareGroups = [ 'api' => [ \Storage\ApiReplay\Http\Middleware\RecordApiRequest::class, // Optional: Add this to enable automatic DB rollback during Dry Run replays \Storage\ApiReplay\Http\Middleware\SimulationMiddleware::class, ], ];
2. Dashboard UI
Access the dashboard at /api-replay in your browser. You can:
- View all recorded API calls.
- Compare original response vs replay response.
- Enable Dry Run Mode to simulate the request without persisting DB changes.
3. Programmatic Safety
Use the ApiReplay helper to skip side-effects (like sending real emails) during a replay:
use Storage\ApiReplay\Support\ApiReplay; if (ApiReplay::isDryRun()) { // Skip sending real SMS or calling external 3rd party APIs return; }
โ๏ธ Configuration
Check config/api-replay.php for options:
enabled: Toggle recording.log_response: Enable/disable response body logging.sensitive_headers: List of headers to mask.sensitive_fields: List of JSON fields to mask.
๐งช Testing
./vendor/bin/phpunit
If you find this package useful, please consider supporting my work: