sbsedv/request-id-bundle 问题修复 & 功能扩展

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

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

sbsedv/request-id-bundle

最新稳定版本:v1.9.0

Composer 安装命令:

composer require sbsedv/request-id-bundle

包简介

A Symfony bundle that adds a unique Request-ID.

README 文档

README

PHPStan PHPCS-Fixer

sbsedv/request-id-bundle

A Symfony bundle that adds a unique Request-ID.

In the configuration examples shown below, the default values are used.

The generic configuration is as follows:

# config/packages/sbsedv_request_id.yaml

sbsedv_request_id:
    generator: "SBSEDV\Bundle\RequestIdBundle\Generator\UuidRequestIdGenerator"
    # generator: "SBSEDV\Bundle\RequestIdBundle\Generator\RequestIdGenerator"
    # generator: 'your_custom_service_id' (must implement RequestIdGeneratorInterface)

    outgoing_http_header: "x-request-id" # http header that will be added
    # outgoing_http_header: false # disables the header creation

    incoming_http_header: false # disabled
    # incoming_http_header: "x-request-id" # request header that contains the Request-ID to use

The incoming http-header is only used when the SBSEDV\Bundle\RequestIdBundle\TrustStrategy\TrustStrategyInterface service trusts the incoming request.
By default the PrivateIpTrustStrategy is registered.

Twig Integration

If your application has the symfony/twig-bundle installed, the request_id twig function is registered.

{# templates/example.html.twig #}

<p>Request-ID: {{ request_id() }}</p>

You can customize the registered twig function name via:

# config/packages/sbsedv_request_id.yaml

sbsedv_request_id:
    twig_function_name: "request_id"

Error Renderer

By default this bundle decorates the error_renderer service and inserts the current request id before the </body> tag.

# config/packages/sbsedv_request_id.yaml

sbsedv_request_id:
    error_renderer_decorator: false # enabled by default

Monolog Integration

If your application has the symfony/monolog-bundle installed, a log processor is registered that adds the request id to each record.

# config/packages/sbsedv_request_id.yaml

sbsedv_request_id:
    monolog_processor:
        key: "request_id" # Key to which the request id will be set
    # monolog_processor: false # disables the processor

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-03