PHPackages                             paysera/lib-rest-client-common - 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. [API Development](/categories/api)
4. /
5. paysera/lib-rest-client-common

ActiveLibrary[API Development](/categories/api)

paysera/lib-rest-client-common
==============================

Base classes/helpers used in REST Clients

2.7.2(9mo ago)5212.1k—3.3%10[4 PRs](https://github.com/paysera/lib-rest-client-common/pulls)5PHPPHP &gt;=7.4

Since Feb 27Pushed 9mo ago9 watchersCompare

[ Source](https://github.com/paysera/lib-rest-client-common)[ Packagist](https://packagist.org/packages/paysera/lib-rest-client-common)[ RSS](/packages/paysera-lib-rest-client-common/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (29)Used By (5)

lib-rest-client-common [![](https://camo.githubusercontent.com/8d622c0e3e9c48ecaab566fe7420d541c7172fc017e7a3eee1857b3f79905c7b/68747470733a2f2f7472617669732d63692e6f72672f706179736572612f6c69622d726573742d636c69656e742d636f6d6d6f6e2e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/8d622c0e3e9c48ecaab566fe7420d541c7172fc017e7a3eee1857b3f79905c7b/68747470733a2f2f7472617669732d63692e6f72672f706179736572612f6c69622d726573742d636c69656e742d636f6d6d6f6e2e7376673f6272616e63683d6d6173746572)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#lib-rest-client-common-)

Generic library for RESTful API clients

#### Usage

[](#usage)

You should create `ClientFactory` class, which extends `ClientFactoryAbstract`. In `ClientFactory` you can override any parent configuration if needed.

Simple example of `ClientFactory`:

```
class TestClientFactory extends ClientFactoryAbstract
{
    const DEFAULT_BASE_URL = 'http://example.com/test/rest/v1/{locale}/';

    private $apiClient;

    public function __construct(array $options)
    {
        $this->apiClient = $this->createApiClient($options);
    }

    public function getTestClient()
    {
        return new TestClient($this->apiClient);
    }
}
```

Using this pattern you can reuse same `ApiClient` with it's authentication and other options in different APIs.

In addition to `ClientFactory`, you should create also the `Client` itself. Finally you will use the `Client` itself, so it should contain all the methods your API provides.

Simple example of `TestClient`:

```
class TestClient
{
    private $apiClient;

    public function __construct(ApiClient $apiClient)
    {
        $this->apiClient = $apiClient;
    }

    public function withOptions(array $options)
    {
        return new TestClient($this->apiClient->withOptions($options));
    }

    /**
     * @return array
     */
    public function getSomething()
    {
        $request = $this->apiClient->createRequest(
            RequestMethodInterface::METHOD_GET,
            sprintf('/something'),
            null
        );
        return $this->apiClient->makeRequest($request);
    }
}
```

You should implement mapping or data transformation where applicable in `TestClient` methods.

#### Example:

[](#example)

```
use Paysera\Client\CategoryClient\ClientFactory;

$clientFactory = new ClientFactory([
    'base_url' => 'custom base url',
    'auth_base_url' => 'custom auth base url',
    'basic' => [
        'username' => 'user',
        'password' => 'pass'
    ],
    'oauth' => [
        'token' => [
            'access_token' => 'your oauth access token',
            'refresh_token' => 'your oauth refresh token',
        ],
    ],
    'mac' => [
        'mac_id' => 'mac id',
        'mac_secret' => 'mac secret',
        'parameters' => [
            // list of needed parameters
        ]
    ],
    'url_parameters' => [
        'locale' => 'en',
        // list of base_url placeholder parameter values
    ],
    'headers' => [
        'Accept-Language' => 'en',
    ],
    // other configuration options
]);

$testClient = $clientFactory->getTestClient();
$data = $testClient->getSomething();
```

- Please note that only single authentication mechanism is supported.

In case you want to change some configuration options at runtime, use `TestClient::withOptions()`:

```
$factory = new TestClientFactory([
    MacAuthentication::TYPE => [
        'mac_id' => $macId,
        'mac_secret' => $macSecret,
        'parameters' => [
            'user_id' => 100,
        ]
    ]
]);

$client = $factory->getTestClient();

$client2 = $factory->getTestClient()->withOptions([
    MacAuthentication::TYPE => [
        'parameters' => ['user_id' => 999],
    ]
]);
```

Here for `$client2` only `user_id` in `parameters` will be changed. Other configuration, like `mac_id`, `mac_secret` will be left intact.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance55

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor3

3 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 ~118 days

Recently: every ~217 days

Total

27

Last Release

299d ago

Major Versions

1.1.1 → 2.0.02018-07-19

PHP version history (2 changes)1.0.0PHP &gt;=5.5

2.7.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d385187c2b529d5c1189dfc3763972f76738d24293593ff3db876fff82321db?d=identicon)[paysera.com](/maintainers/paysera.com)

---

Top Contributors

[![borilyordanov](https://avatars.githubusercontent.com/u/11679283?v=4)](https://github.com/borilyordanov "borilyordanov (4 commits)")[![vbartusevicius](https://avatars.githubusercontent.com/u/7325630?v=4)](https://github.com/vbartusevicius "vbartusevicius (3 commits)")[![aliaksandr-lishko](https://avatars.githubusercontent.com/u/161292120?v=4)](https://github.com/aliaksandr-lishko "aliaksandr-lishko (2 commits)")[![tomas7777](https://avatars.githubusercontent.com/u/9091359?v=4)](https://github.com/tomas7777 "tomas7777 (2 commits)")[![mariusbalcytis](https://avatars.githubusercontent.com/u/1590072?v=4)](https://github.com/mariusbalcytis "mariusbalcytis (1 commits)")[![mSprunskas](https://avatars.githubusercontent.com/u/4427922?v=4)](https://github.com/mSprunskas "mSprunskas (1 commits)")[![oleksandr-gribiennikov-paysera](https://avatars.githubusercontent.com/u/148878964?v=4)](https://github.com/oleksandr-gribiennikov-paysera "oleksandr-gribiennikov-paysera (1 commits)")[![Laurgrin](https://avatars.githubusercontent.com/u/15212775?v=4)](https://github.com/Laurgrin "Laurgrin (1 commits)")[![ezgass](https://avatars.githubusercontent.com/u/3251505?v=4)](https://github.com/ezgass "ezgass (1 commits)")[![feraldrood](https://avatars.githubusercontent.com/u/7203522?v=4)](https://github.com/feraldrood "feraldrood (1 commits)")[![alexanderzaiets-paysera](https://avatars.githubusercontent.com/u/101864629?v=4)](https://github.com/alexanderzaiets-paysera "alexanderzaiets-paysera (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/paysera-lib-rest-client-common/health.svg)

```
[![Health](https://phpackages.com/badges/paysera-lib-rest-client-common/health.svg)](https://phpackages.com/packages/paysera-lib-rest-client-common)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[saloonphp/saloon

Build beautiful API integrations and SDKs with Saloon

2.4k9.6M468](/packages/saloonphp-saloon)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)

PHPackages © 2026

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