承接 mxnwire/laravel-request-id 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mxnwire/laravel-request-id

Composer 安装命令:

composer require mxnwire/laravel-request-id

包简介

Propagate request, session and correlation IDs across requests, responses and log records

README 文档

README

Propagate request, session and correlation IDs across the request lifecycle: read them from incoming headers, echo them on the response, and attach them (plus the authenticated user) to every log record.

  • X-Request-Id — taken from the incoming header or generated as a UUID v4.
  • X-Session-Id / X-Correlation-Id — propagated from upstream only; left null when absent.

Only valid UUID v4 values are accepted from upstream; anything else is treated as absent (and regenerated for request_id).

Installation

composer require mxnwire/laravel-request-id

The service provider is auto-discovered. By default the middleware is prepended to the global HTTP stack, so every request is covered with no further setup.

Configuration

Publish the config to customise behaviour:

php artisan vendor:publish --tag=request-id-config

Key options in config/request-id.php:

  • enabled — master switch; when false the middleware passes requests through untouched.
  • register_global_middleware — when false, register manually with the request-id alias instead of the global stack.
  • headers — the incoming/outgoing header name for each ID.
  • generate — which IDs are generated as a UUID v4 when missing (default: request_id only).
  • attributes — the $request->attributes keys the IDs are stored under.
  • log_channels — extra log channels to attach the processor to (the default driver is always covered).
  • log_user / user_fields — attach authenticated-user fields to each log record; each field is a model attribute name or a callable receiving the user.

Manual middleware registration

Set register_global_middleware to false, then apply the alias where needed:

Route::middleware('request-id')->group(function () {
    // ...
});

Reading the IDs

$requestId = $request->attributes->get('x_request_id');

Testing

composer install
composer test

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固