farzai/laravel-http-recorder

一个简单的Laravel HTTP记录器

1.0.1 2023-05-01 10:21 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

此包允许您记录Laravel应用程序中的所有HTTP请求。

安装

您可以通过Composer安装此包

composer require farzai/laravel-http-recorder

准备数据库

您需要发布迁移以创建http_log_requests

php artisan vendor:publish --tag="http-recorder-migrations"

之后,您需要运行迁移

php artisan migrate

发布配置文件

发布配置文件是可选的

php artisan vendor:publish --tag="http-recorder-config"

这是已发布配置文件的内容

return [
    /*
     * Enable or disable the http recorder.
     */
    'enabled' => env('HTTP_RECORDER_ENABLED', true),

    /*
     * The driver used to store the http logs.
     * It should be a class that implements the `Farzai\HttpRecorder\Contracts\EntryRepositoryInterface`.
     *
     * Supported drivers: "database"
     */
    'driver' => env('HTTP_RECORDER_DRIVER', 'database'),

    /**
     * Process the request in the background.
     * (leave it to empty to use default queue)
     */
    'queue' => env('HTTP_RECORDER_QUEUE'),
    // 'queue' => [
    //     'connection' => env('HTTP_RECORDER_QUEUE_CONNECTION'),
    //     'queue' => env('HTTP_RECORDER_QUEUE_NAME'),
    // ]

    /*
     * Exclude routes from being logged.
     */
    'except' => [
        'urls' => [
            'telescope*',
            'horizon*',
            'nova*',
        ],

        'methods' => [
            'HEAD',
        ],
    ],

    /**
     * Drivers
     */
    'drivers' => [
        'database' => [
            'connection' => env('HTTP_RECORDER_CONNECTION'),
            'table' => env('HTTP_RECORDER_DB_TABLE', 'http_log_requests'),
        ],
    ],

    /**
     * Sensitive request headers and response.
     * 
     * These fields will be replaced with asterisks (*) in the request headers.
     */
    'sensitive' => [
        'headers' => [
            'authorization',
            'x-csrf-token',
            'x-xsrf-token',
            'set-cookie',
        ],
        'body' => [
            'password',
            'password_confirmation',
            'token',
            'access_token',
        ],
    ],

    /**
     * The maximum length of the request body and response body.
     *
     * If the length of the request body or response body exceeds the maximum length,
     * it will be truncated to the maximum length.
     */
    'size_limit' => 64
];

测试

composer test

更新日志

请参阅更新日志以获取有关最近更改的更多信息。

贡献

请参阅贡献指南以获取详细信息。

安全漏洞

请查看我们的安全策略,了解如何报告安全漏洞。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。