nhatnathando/laravel-api-replay 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nhatnathando/laravel-api-replay

Composer 安装命令:

composer require --dev nhatnathando/laravel-api-replay

包简介

Log, store, and replay Laravel API requests.

README 文档

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

  1. Install via composer:
composer require nhatnathando/laravel-api-replay

View on Packagist

  1. 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"
  1. 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:

Buy Me a Coffee at ko-fi.com

nhatnathando/laravel-api-replay 适用场景与选型建议

nhatnathando/laravel-api-replay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「debug」 「api」 「testing」 「laravel」 「replay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nhatnathando/laravel-api-replay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nhatnathando/laravel-api-replay 我们能提供哪些服务?
定制开发 / 二次开发

基于 nhatnathando/laravel-api-replay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-03