PHPackages                             salesrender/plugin-component-guzzle - 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. salesrender/plugin-component-guzzle

ActiveLibrary

salesrender/plugin-component-guzzle
===================================

SalesRender plugin guzzle helper

0.3.3(2y ago)01.1k↓100%3proprietaryPHPPHP &gt;=7.4.0

Since Feb 11Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/SalesRender/plugin-component-guzzle)[ Packagist](https://packagist.org/packages/salesrender/plugin-component-guzzle)[ RSS](/packages/salesrender-plugin-component-guzzle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (10)Used By (3)

salesrender/plugin-component-guzzle
===================================

[](#salesrenderplugin-component-guzzle)

Singleton wrapper around GuzzleHttp providing an HTTP client with a SalesRender plugin-specific User-Agent header.

Overview
--------

[](#overview)

This component provides a thin abstraction over the GuzzleHttp `Client`, exposing it through a static singleton factory. Its primary purpose is to ensure that every HTTP request made by a SalesRender plugin carries a standardized `User-Agent` header that identifies the plugin type and its public endpoint.

The User-Agent format follows the convention:

```
SR-PLUGIN-{TYPE}-BOT/1.0 (+{SELF_URI}/info)

```

For example, a macros plugin hosted at `https://plugin.example.com/excel` would send:

```
SR-PLUGIN-MACROS-BOT/1.0 (+https://plugin.example.com/excel/info)

```

The plugin type is resolved from the `Info` component configuration, and the base URI comes from the `LV_PLUGIN_SELF_URI` environment variable. This makes all outgoing HTTP traffic from SalesRender plugins easily identifiable by external services.

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

[](#installation)

```
composer require salesrender/plugin-component-guzzle
```

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

[](#requirements)

- PHP &gt;= 7.4
- [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) ^6.5
- [salesrender/plugin-component-info](https://github.com/SalesRender/plugin-component-info) ^0.1.2

Key Classes
-----------

[](#key-classes)

### `Guzzle`

[](#guzzle)

**Namespace:** `SalesRender\Plugin\Components\Guzzle`

Static singleton factory that creates and returns a configured GuzzleHttp `Client` instance.

The constructor is private -- the only way to obtain a client is through the `getInstance()` static method.

#### Methods

[](#methods)

MethodSignatureDescription`getInstance``static getInstance(array $config = []): \GuzzleHttp\Client`Returns the singleton GuzzleHttp `Client`. On the first call, creates the client by merging the provided `$config` with the default User-Agent header. Subsequent calls return the same instance (the `$config` argument is only applied on the first call).Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use SalesRender\Plugin\Components\Guzzle\Guzzle;

// Get the singleton HTTP client
$client = Guzzle::getInstance();

// Make a GET request
$response = $client->get('https://api.example.com/data');
$body = $response->getBody()->getContents();
```

### Passing Custom Configuration

[](#passing-custom-configuration)

You can pass additional GuzzleHttp configuration options on the first call. These are merged recursively with the default User-Agent header:

```
use SalesRender\Plugin\Components\Guzzle\Guzzle;

$client = Guzzle::getInstance([
    'timeout' => 30,
    'headers' => [
        'Accept' => 'application/json',
    ],
]);
```

> **Note:** The `$config` parameter is only used when the singleton is first created. Subsequent calls to `getInstance()` return the already-created instance regardless of the arguments passed.

### Making API Requests

[](#making-api-requests)

The returned object is a standard `GuzzleHttp\Client`, so all Guzzle methods are available:

```
use SalesRender\Plugin\Components\Guzzle\Guzzle;

// POST request with JSON body
$response = Guzzle::getInstance()->request('POST', 'https://api.example.com/orders', [
    'json' => ['order_id' => 12345],
]);

// GET request
$publicKey = Guzzle::getInstance()->get($uri)->getBody()->getContents();

// PUT request
$response = Guzzle::getInstance()->put($uri, [
    'json' => $payload,
]);
```

### Usage in Other SalesRender Components

[](#usage-in-other-salesrender-components)

The `Guzzle` singleton is used throughout the SalesRender plugin ecosystem:

```
// In plugin-component-access (Registration)
return Guzzle::getInstance()->request(
    'PUT',
    $uri,
    ['json' => $requestBody]
);

// In plugin-component-api-client
$this->client = Guzzle::getInstance([
    'base_uri' => $endpoint,
    'headers' => [
        'Authorization' => "Bearer {$token}",
    ],
]);

// In plugin-component-special-request
$response = Guzzle::getInstance()->request(
    $method,
    $uri,
    $options
);
```

Configuration
-------------

[](#configuration)

The component requires two things to be configured before use:

### 1. Environment Variable

[](#1-environment-variable)

Set the `LV_PLUGIN_SELF_URI` environment variable to the plugin's public base URL:

```
LV_PLUGIN_SELF_URI=https://plugin.example.com/excel

```

This value is used as part of the User-Agent string. The trailing slash is automatically trimmed.

### 2. Plugin Info

[](#2-plugin-info)

The [`salesrender/plugin-component-info`](https://github.com/SalesRender/plugin-component-info) package must be configured so that the plugin type (e.g., `MACROS`, `LOGISTIC`, `CHAT`) can be resolved:

```
use SalesRender\Plugin\Components\Info\Info;
use SalesRender\Plugin\Components\Info\PluginType;

Info::config(
    new PluginType(PluginType::MACROS),
    'Plugin Name',
    'Plugin Description',
    $extra,
    $developer
);
```

The plugin type is included in the User-Agent header. Available types: `MACROS`, `LOGISTIC`, `PBX`, `CHAT`, `GEOCODER`, `INTEGRATION`, `RESALE`.

### User-Agent Format

[](#user-agent-format)

The resulting User-Agent header follows this pattern:

```
SR-PLUGIN-{TYPE}-BOT/1.0 (+{SELF_URI}/info)

```

Examples:

- `SR-PLUGIN-MACROS-BOT/1.0 (+https://plugin.example.com/excel/info)`
- `SR-PLUGIN-LOGISTIC-BOT/1.0 (+https://logistic.example.com/cdek/info)`
- `SR-PLUGIN-CHAT-BOT/1.0 (+https://chat.example.com/wazzup/info)`

API Reference
-------------

[](#api-reference)

### `Guzzle`

[](#guzzle-1)

```
final class Guzzle
{
    private function __construct();
    public static function getInstance(array $config = []): \GuzzleHttp\Client;
}
```

**Parameters:**

- `$config` (array, optional) -- GuzzleHttp configuration array. Merged recursively with the default configuration using `array_merge_recursive()`. Only applied on the first invocation. Default: `[]`.

**Returns:**

- `\GuzzleHttp\Client` -- A configured GuzzleHttp client singleton with the SalesRender User-Agent header.

**Behavior:**

1. On the first call, reads `$_ENV['LV_PLUGIN_SELF_URI']` and `Info::getInstance()->getType()`
2. Creates a new `GuzzleHttp\Client` by merging the provided `$config` with the User-Agent header
3. Stores the client instance in a private static property
4. On subsequent calls, returns the stored instance

Dependencies
------------

[](#dependencies)

PackageVersionPurpose`guzzlehttp/guzzle`^6.5The underlying HTTP client library`salesrender/plugin-component-info`^0.1.2Provides the plugin type for the User-Agent string via `Info::getInstance()->getType()`See Also
--------

[](#see-also)

- [salesrender/plugin-component-access](https://github.com/SalesRender/plugin-component-access) -- Uses `Guzzle::getInstance()` for plugin registration and public key retrieval
- [salesrender/plugin-component-api-client](https://github.com/SalesRender/plugin-component-api-client) -- Uses `Guzzle::getInstance()` as the base HTTP client for API calls
- [salesrender/plugin-component-special-request](https://github.com/SalesRender/plugin-component-special-request) -- Uses `Guzzle::getInstance()` for handling special request forwarding
- [salesrender/plugin-component-info](https://github.com/SalesRender/plugin-component-info) -- Provides the `Info` singleton used to build the User-Agent header

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance59

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~175 days

Recently: every ~304 days

Total

9

Last Release

878d ago

PHP version history (2 changes)0.0.1PHP &gt;=7.1.0

0.3.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6140af7bf37913fbad3d596efa1376ede23a55ac226a15b61857f4e58fc26c22?d=identicon)[SalesRender](/maintainers/SalesRender)

---

Top Contributors

[![IvanKalashnikov](https://avatars.githubusercontent.com/u/6877306?v=4)](https://github.com/IvanKalashnikov "IvanKalashnikov (1 commits)")[![LightFuri](https://avatars.githubusercontent.com/u/46054834?v=4)](https://github.com/LightFuri "LightFuri (1 commits)")[![XAKEPEHOK](https://avatars.githubusercontent.com/u/3051649?v=4)](https://github.com/XAKEPEHOK "XAKEPEHOK (1 commits)")

### Embed Badge

![Health badge](/badges/salesrender-plugin-component-guzzle/health.svg)

```
[![Health](https://phpackages.com/badges/salesrender-plugin-component-guzzle/health.svg)](https://phpackages.com/packages/salesrender-plugin-component-guzzle)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k20](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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