muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher 为通过 guzzlehttp/guzzle PHP 库发出的 HTTP 请求提供自定义监视器。该包使用 on_stats 请求选项来提取请求/响应数据。监视器拦截并记录请求到 Laravel Telescope HTTP 客户端监视器。

v3.1.0 2024-07-02 16:55 UTC

This package is auto-updated.

Last update: 2024-09-02 17:17:45 UTC


README

StandWithPalestine

Telescope Guzzle Watcher

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Telescope Guzzle Watcher 提供了一个用于拦截通过 guzzlehttp/guzzle PHP 库发出的 HTTP 请求的自定义监视器。该包使用 on_stats 请求选项来提取请求/响应数据。监视器拦截并记录请求到 Laravel TelescopeHTTP 客户端监视器

安装和配置完成后,您可以在 telescope/client-requests 下查看请求日志。

安装

您可以通过 composer 安装此包。

composer require muhammadhuzaifa/telescope-guzzle-watcher

使用

您可以使用以下命令发布配置文件:

php artisan vendor:publish --tag="telescope-guzzle-watcher-config"

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

return [

    /*
    |--------------------------------------------------------------------------
    | Except Request Headers
    |--------------------------------------------------------------------------
    |
    | This value is used when you need to exclude the request headers from
    | being recorded under the telescope. You can exclude any number of
    | headers containing sensitive information
    |
    */

    'except_request_headers' => [],

    /*
    |--------------------------------------------------------------------------
    | Except Response Headers
    |--------------------------------------------------------------------------
    |
    | This value is used when you need to exclude the response headers from
    | being recorded under the telescope. You can exclude any number of
    | headers containing sensitive information
    |
    */

    'except_response_headers' => [],

    /*
    |--------------------------------------------------------------------------
    | Enable URI Tags
    |--------------------------------------------------------------------------
    |
    | This value is used for determining wether the watcher should parse the url
    | and add it's segments as telescope tags
    |
    |
    */

    'enable_uri_tags' => true,

    /*
    |--------------------------------------------------------------------------
    | Exclude words from URI tags
    |--------------------------------------------------------------------------
    |
    | This value is used when you need to exclude words or patterns that should
    | be excluded from the tags list
    |
    */

    'exclude_words_from_uri_tags' => [],

    /*
    |--------------------------------------------------------------------------
    | Content Size Limit
    |--------------------------------------------------------------------------
    |
    | This value is used when you need to limit the response content.
    | Default is 64.
    |
    */

    'size_limit' => null,
];

您可以设置需要排除的头部,例如 API 密钥或其他敏感信息。您还可以通过将它们转换为数组来标记 URI 段。此功能可以切换为 true/false。

编辑 config/telescope.php 文件并添加监视器

return [
    // other telescope configurations
     \MuhammadHuzaifa\TelescopeGuzzleWatcher\Watchers\TelescopeGuzzleWatcher::class,
];

监视器依赖于 Service Container,并且每个 guzzle 客户端实例都必须使用 Service Container 来解析。

$client = app(\GuzzleHttp\Client::class); // will work
$client = new \GuzzleHttp\Client(); // will not work

变更日志

有关最近更改的更多信息,请参阅 CHANGELOG

鸣谢

其他项目

  • Laravel Pulse Guzzle Recorder
    • Laravel Pulse Guzzle Recorder 为通过 guzzlehttp/guzzle PHP 库发出的 HTTP 请求提供了一个自定义记录器,并将它们记录到 Laravel Pulse 慢速出站请求部分。

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件