PHPackages                             muhammadhuzaifa/telescope-guzzle-watcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. muhammadhuzaifa/telescope-guzzle-watcher

ActiveLibrary[HTTP &amp; Networking](/categories/http)

muhammadhuzaifa/telescope-guzzle-watcher
========================================

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

v4.1.0(5mo ago)98300.5k—0.5%5[2 issues](https://github.com/huzaifaarain/telescope-guzzle-watcher/issues)1MITPHPPHP ^8.4CI passing

Since Apr 10Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/huzaifaarain/telescope-guzzle-watcher)[ Packagist](https://packagist.org/packages/muhammadhuzaifa/telescope-guzzle-watcher)[ Docs](https://github.com/huzaifaarain/telescope-guzzle-watcher)[ RSS](/packages/muhammadhuzaifa-telescope-guzzle-watcher/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (20)Versions (17)Used By (1)

We Stand With Palestine, Pakistan Stand With Palestine
======================================================

[](#we-stand-with-palestine-pakistan-stand-with-palestine)

[![StandWithPalestine](https://raw.githubusercontent.com/huzaifaarain/huzaifaarain/master/assets/solidarity-palestine.png)](https://raw.githubusercontent.com/huzaifaarain/huzaifaarain/master/assets/solidarity-palestine.png)

Telescope Guzzle Watcher
------------------------

[](#telescope-guzzle-watcher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3a2ea93c27bb857cf539427679557e65fd78457f3f56798822a983c8a61011ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7568616d6d616468757a616966612f74656c6573636f70652d67757a7a6c652d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhammadhuzaifa/telescope-guzzle-watcher)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bef6b69b7ed0839200ac46208507ec720b2d98c151fd0b290a2b808fb6bdea68/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68757a61696661617261696e2f74656c6573636f70652d67757a7a6c652d776174636865722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/huzaifaarain/telescope-guzzle-watcher/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/5c524fafc3fea8f5eed820ca9755e715ba8c3c0969e24ea9e723c037cf7a465b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7568616d6d616468757a616966612f74656c6573636f70652d67757a7a6c652d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhammadhuzaifa/telescope-guzzle-watcher)

---

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) php library. The package uses the [on\_stats](https://docs.guzzlephp.org/en/stable/request-options.html#on-stats) request option for extracting the request/response data. The watcher intercept and log the request into the [Laravel Telescope](https://laravel.com/docs/telescope) [HTTP Client Watcher](https://laravel.com/docs/telescope#http-client-watcher).

Once the installation and configurations are completed, you will be able to see the request logs under `telescope/client-requests`

Table of Contents
-----------------

[](#table-of-contents)

- [We Stand With Palestine, Pakistan Stand With Palestine](#we-stand-with-palestine-pakistan-stand-with-palestine)
    - [Telescope Guzzle Watcher](#telescope-guzzle-watcher)
    - [Table of Contents](#table-of-contents)
    - [Requirements](#requirements)
    - [Installation](#installation)
    - [How It Works](#how-it-works)
    - [Configuration Reference](#configuration-reference)
    - [Registering the Watcher](#registering-the-watcher)
    - [Resolving Guzzle Clients](#resolving-guzzle-clients)
    - [Using Multiple Clients](#using-multiple-clients)
    - [Integration Example: HubSpot PHP SDK](#integration-example-hubspot-php-sdk)
    - [Testing &amp; Verification](#testing--verification)
    - [Troubleshooting](#troubleshooting)
    - [Changelog](#changelog)
    - [Credits](#credits)
    - [Other Projects](#other-projects)
    - [License](#license)

Requirements
------------

[](#requirements)

- PHP ^8.4
- Laravel 12.x
- [Laravel Telescope](https://laravel.com/docs/telescope) ^5.11
- [Guzzle](https://github.com/guzzle/guzzle) ^7.9

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require muhammadhuzaifa/telescope-guzzle-watcher
```

Laravel's package auto-discovery will register the service provider for you. No manual provider entry is required unless auto-discovery is disabled.

After the package is installed, publish the configuration file so that you can tweak the watcher defaults:

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

The published file lives at `config/telescope-guzzle-watcher.php`.

How It Works
------------

[](#how-it-works)

1. **Client Hijacking via the Container** – The package binds `GuzzleHttp\Client` in the service container to a custom [Guzzle Client Factory](src/GuzzleClientFactory.php). Every time a client is resolved from the container, the factory injects an `on_stats` callback that forwards request and response information to Telescope.
2. **Transfer Stats Hook** – Guzzle fires the `on_stats` callback when a request completes (successfully or not). The watcher converts the raw PSR-7 request/response objects into Laravel's `Illuminate\Http\Client\Request` and `Response` wrappers so that Telescope can index the payload.
3. **Telescope Recording** – When Telescope is actively recording, the watcher forwards each HTTP transfer to the `client-requests` panel, applying configuration such as tag extraction, payload truncation, and header redaction.

Because the watcher is a first-class Telescope watcher, it benefits from all Telescope filters, tags, and search capabilities right out of the box.

Configuration Reference
-----------------------

[](#configuration-reference)

The configuration file ships with the following options:

KeyTypeDefaultDescription`except_request_headers``array``[]`Header names (case-insensitive) that should be hidden from Telescope for outgoing requests. Useful for API keys or authorization tokens.`except_response_headers``array``[]`Header names that should be hidden from Telescope responses.`enable_uri_tags``bool``true`When `true`, the watcher will explode the request URI into segments and push them as Telescope tags (`host`, followed by each non-empty path segment).`exclude_words_from_uri_tags``array``[]`List of words that should be excluded from the tag list after it is generated. Matching is case-insensitive.`size_limit``intnull``null`Tweak these settings in `config/telescope-guzzle-watcher.php` and cache your configuration if your deployment workflow requires it (`php artisan config:cache`).

Registering the Watcher
-----------------------

[](#registering-the-watcher)

Tell Telescope to use this watcher by updating your `config/telescope.php` file:

```
// config/telescope.php

return [
    'watchers' => [
        // ... other watchers ...
        \MuhammadHuzaifa\TelescopeGuzzleWatcher\Watchers\TelescopeGuzzleWatcher::class => true,
    ],
];
```

Set the value to `true` to enable it or to a configuration array if you want to supply watcher-specific options in-line (for example, to disable it per-environment using a closure).

Resolving Guzzle Clients
------------------------

[](#resolving-guzzle-clients)

For the watcher to intercept traffic you must resolve Guzzle clients through Laravel's service container:

```
// Correct – the factory will wire up on_stats and Telescope logging
$client = app(\GuzzleHttp\Client::class);

// Optional custom configuration
$client = app(\GuzzleHttp\Client::class, [
    'config' => [
        'base_uri' => 'https://api.example.com',
        'timeout' => 5,
    ],
]);

// Avoid instantiating Guzzle manually if you want Telescope coverage
$client = new \GuzzleHttp\Client(); // no Telescope logging
```

If you already provide an `on_stats` callback, the factory will wrap it so both Telescope and your callback execute.

Using Multiple Clients
----------------------

[](#using-multiple-clients)

The watcher supports any number of clients or middleware stacks as long as they are resolved through the container. A few patterns you may find useful:

- **Per-service bindings:**

    ```
    $this->app->bind('billing-client', function () {
        return app(\GuzzleHttp\Client::class, [
            'config' => [
                'base_uri' => config('services.billing.url'),
                'headers' => ['Accept' => 'application/json'],
            ],
        ]);
    });
    ```
- **Custom middleware:** resolve the client as normal, then push additional middleware. Telescope will continue to receive the transfer statistics.

Integration Example: HubSpot PHP SDK
------------------------------------

[](#integration-example-hubspot-php-sdk)

The [HubSpot PHP SDK](https://github.com/HubSpot/hubspot-api-php) ships with a Pluggable HTTP client stack. To hook it into Telescope you only need to hand it a Guzzle client from the container.

1. **Install the SDK**

    ```
    composer require hubspot/api-client
    ```
2. **Bind a HubSpot client that reuses the Telescope-aware Guzzle client**

    ```
    use HubSpot\Factory\HubSpotFactory;
    use HubSpot\Discovery\Discovery;

    $this->app->singleton(Discovery::class, function ($app) {
        $guzzle = $app->make(\GuzzleHttp\Client::class, [
            'config' => [
                'base_uri' => 'https://api.hubapi.com',
                'timeout' => 10,
            ],
        ]);

        return HubSpot\Factory::createWithAccessToken(
            'your-access-token',
            $guzzle
        );
    });
    ```

    Adjust the configuration array to include proxies, retry middleware, or any other Guzzle options your integration needs.
3. **Use the client**

    ```
    use HubSpot\Discovery\Discovery;

    Route::get('/hubspot/contacts', function (Discovery $hubspot) {
        return $hubspot->crm()->contacts()->basicApi()->getPage()->toArray();
    });
    ```

    Each call will now appear in Telescope under `Client Requests`, tagged with `api.hubapi.com` and the path segments (unless you disable URI tagging).

> **Tip:** HubSpot APIs enforce rate limits. Telescope will record both successful responses and 429 errors so you can diagnose throttling in development.

Testing &amp; Verification
--------------------------

[](#testing--verification)

1. Run a request through your application that uses the container-resolved Guzzle client.
2. Visit `https://your-app.test/telescope/client-requests` (or the path configured for Telescope) to verify the entry.
3. Adjust configuration options and clear caches as needed.

Automated testing tips:

- The package itself is tested with [Orchestra Testbench](https://github.com/orchestral/testbench). If you write integration tests, boot Telescope or fake it appropriately to avoid polluting production storage.
- You can disable Telescope during certain tests with `Telescope::withoutRecording(fn () => /* perform requests */);` if you only want to test the client behavior.

Troubleshooting
---------------

[](#troubleshooting)

- **No entries appear:** Confirm that Telescope is enabled (`TELESCOPE_ENABLED=true`) and that you are resolving Guzzle via the container. Telescope only records when `Telescope::isRecording()` returns `true`.
- **Entries missing payloads:** Increase `size_limit` in the package config or ensure the response body is seekable. Streams that cannot be rewound will be labeled as `Stream Response` by Telescope.
- **Headers still visible:** Remember that header names are case-insensitive; ensure you use the exact header key (for example, `Authorization`) in the `except_*` arrays.
- **Existing on\_stats logic not firing:** The factory preserves your callback. If you replace the client configuration elsewhere, make sure you merge with the container-provided config instead of instantiating a fresh client.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Huzaifa Saif-ur-Rehman](https://muhammadhuzaifa.pro)

Other Projects
--------------

[](#other-projects)

- [Laravel Pulse Guzzle Recorder](https://packagist.org/packages/muhammadhuzaifa/laravel-pulse-guzzle-recorder)
    - Laravel Pulse Guzzle Recorder provide a custom recorder for intercepting http requests made via guzzlehttp/guzzle php library and log them into the Laravel Pulse Slow Outgoing Requests section.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance72

Regular maintenance activity

Popularity50

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 52.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~82 days

Recently: every ~94 days

Total

14

Last Release

152d ago

Major Versions

v1.2.0 → v2.0.02023-05-29

v2.0.1 → v3.0.02024-03-17

3.x-dev → 4.x-dev2025-09-26

PHP version history (2 changes)1.0.0PHP ^8.0.2|^8.1|^8.2

3.x-devPHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc1c37056f779b40cadc67a30b0159e53f468e01bceb5a4f805b7264539cf973?d=identicon)[muhammadhuzaifa](/maintainers/muhammadhuzaifa)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (332 commits)")[![huzaifaarain](https://avatars.githubusercontent.com/u/8613679?v=4)](https://github.com/huzaifaarain "huzaifaarain (103 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (46 commits)")[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (16 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (14 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (7 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (7 commits)")[![irfanm96](https://avatars.githubusercontent.com/u/42065936?v=4)](https://github.com/irfanm96 "irfanm96 (5 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (5 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (4 commits)")[![IGedeon](https://avatars.githubusercontent.com/u/694313?v=4)](https://github.com/IGedeon "IGedeon (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![abenerd](https://avatars.githubusercontent.com/u/7523903?v=4)](https://github.com/abenerd "abenerd (3 commits)")[![koossaayy](https://avatars.githubusercontent.com/u/6431084?v=4)](https://github.com/koossaayy "koossaayy (3 commits)")[![willemvb](https://avatars.githubusercontent.com/u/1336390?v=4)](https://github.com/willemvb "willemvb (3 commits)")[![medilies](https://avatars.githubusercontent.com/u/35309918?v=4)](https://github.com/medilies "medilies (3 commits)")

---

Tags

guzzlehttplaravelphptelescopelaraveltelescopeMuhammad Huzaifaguzzlehttp telescope watcherguzzle telescope watchercustom http client watcher

###  Code Quality

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/muhammadhuzaifa-telescope-guzzle-watcher/health.svg)

```
[![Health](https://phpackages.com/badges/muhammadhuzaifa-telescope-guzzle-watcher/health.svg)](https://phpackages.com/packages/muhammadhuzaifa-telescope-guzzle-watcher)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M189](/packages/spatie-laravel-health)[nativephp/mobile

NativePHP for Mobile

1.1k102.1k151](/packages/nativephp-mobile)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

33746.5k](/packages/sunchayn-nimbus)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
