deuzu/request-collector-bundle

此包已被废弃,不再维护。没有推荐替代包。

HTTP请求收集器

安装次数: 29,821

依赖: 0

建议者: 0

安全性: 0

星标: 7

关注者: 1

分支: 2

开放问题: 1

类型:symfony-bundle

1.1.0 2017-05-26 21:30 UTC

This package is not auto-updated.

Last update: 2022-01-08 02:54:08 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

请求收集器Symfony包收集来自各种互联网服务(webhooks、api)或本地调用的HTTP请求。它公开一个URL,该URL将持久化、记录和/或通过电子邮件发送接收到的请求。收集到的HTTP请求包含头部、查询字符串参数、POST/表单参数以及请求的正文/内容。

它将帮助您检查、调试或处理webhooks/api请求。

您还可以添加自己的自定义服务,该服务将在收集过程之后执行,方法是在您的应用程序中标记一个Symfony服务(CF扩展)。

安装

composer require deuzu/request-collector-bundle

app/AppKernel.php

$bundles = array(
    // ...
    new Deuzu\RequestCollectorBundle\DeuzuRequestCollectorBundle(),
);

app/config/routing.yml

deuzu_request_collector:
    resource: .
    type: request_collector

app/config/config.yml

framework:
    # ...
    serializer: { enable_annotations: true }

deuzu_request_collector:
    collectors:
        default:
            route_path: /request-collector/collect

您需要配置一个收集器及其route_path。默认情况下,收集器仅持久化请求。

如果需要,创建Doctrine模式

$ php app/console doctrine:database:create
$ php app/console doctrine:schema:create

...或更新它

$ php app/console doctrine:schema:update --force

完成。要测试它,请尝试访问配置的URL,然后在末尾添加/inspect以查看持久化的请求。日志位于log文件夹中,默认名为request_collector.log

配置

app/config/config.yml

deuzu_request_collector:
    assets:
        bootstrap3_css: true # or bundles/your_app/css/bootstrap.min.css
        bootstrap3_js: true  # or bundles/your_app/js/bootstrap.min.js
        jquery: true         # or bundles/your_app/js/jquery.min.js
    collectors:
        default:
            route_path: /what/ever/you/want
        github:
            route_path: /github/webhook
            logger:
                enabled: true
                channel: github
            mailer:
                enabled: true
                email: florian.touya@gmail.com
            persister:
                enabled: true

如果您使用不同的通道,请将其添加到monolog配置中

app/config/config.yml

monolog:
    channels: ['github']
    handlers:
        # ...
        github:
            type: stream
            path: '%kernel.logs_dir%/%kernel.environment%.github.log'
            level: debug
            channels: [github]

扩展

如果您想在收集过程之后添加自己的自定义服务,只需像这样标记它即可

post_collect_handler.default:
    class: AppBundle\Service\CustomPostCollectHandler
    tags:
        - { name: request_collector.post_collect_handler, alias: collector_name }

您的自定义服务必须实现Deuzu\RequestCollectorBundle\PostCollectHandler\PostCollectHandlerInterface

待办事项

  • contributing.md, pr_template.md
  • 具有不同收集器的菜单
    • 复制收集地址的按钮
    • 检查所有收集器的操作
  • 改进模板
    • 过滤器
  • 添加翻译(仅英文)