PHPackages                             uzdevid/conflux-http - 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. uzdevid/conflux-http

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

uzdevid/conflux-http
====================

Conflux HTTP — This is a flexible architecture for integration with external HTTP services, built on the basis of the PSR-18 and Guzzle. Each request is made out as a separate class that implements the necessary interfaces, providing readability, testability and expansion.

1.2.0(1y ago)339MITPHPPHP &gt;=8.3

Since Apr 7Pushed 1y agoCompare

[ Source](https://github.com/uzdevid/conflux-http)[ Packagist](https://packagist.org/packages/uzdevid/conflux-http)[ RSS](/packages/uzdevid-conflux-http/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

 [ ![Yii](https://private-user-images.githubusercontent.com/167644693/420289040-e29daa5f-ac8f-47aa-b927-40400a6b5626.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MTMzMTEsIm5iZiI6MTc3NTUxMzAxMSwicGF0aCI6Ii8xNjc2NDQ2OTMvNDIwMjg5MDQwLWUyOWRhYTVmLWFjOGYtNDdhYS1iOTI3LTQwNDAwYTZiNTYyNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwNlQyMjAzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00OTc3MjFiZWZjYjZhNDU2NTIzOGVmZWM5ZmY4YzNlMzc2YjY3Y2JkYjEwNGYxZTViODZmMzE0ZjFhOGE5NGMyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.c2G8hgLIdCmZJXJb9XgyZ3ZsMevVkpbLrC8JNAEkCbo) ](https://github.com/uzdevid)

Conflux HTTP
============

[](#conflux-http)

[![Latest Stable Version](https://camo.githubusercontent.com/068dc51057f9d87d5e0526819f3c0e61bfc34bd7979fe34718ff70b420ddcef3/68747470733a2f2f706f7365722e707567782e6f72672f757a64657669642f636f6e666c75782d687474702f76)](https://packagist.org/packages/uzdevid/conflux-http)[![Total Downloads](https://camo.githubusercontent.com/5294a54365952bc8630cf98631cc59fd0f813c340438f67e6f4e9c062b45bfb1/68747470733a2f2f706f7365722e707567782e6f72672f757a64657669642f636f6e666c75782d687474702f646f776e6c6f616473)](https://packagist.org/packages/uzdevid/conflux-http)

Conflux HTTP — This is a flexible architecture for integration with external HTTP services, built on the basis of the PSR-18 and Guzzle. Each request is made out as a separate class that implements the necessary interfaces, providing readability, testability and expansion.

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

[](#requirements)

- PHP 8.3 or higher.

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

[](#installation)

The package could be installed with [Composer](https://getcomposer.org):

```
composer require uzdevid/conflux-http
```

Quick start
-----------

[](#quick-start)

### 1. Configuration

[](#1-configuration)

```
class GithubConfig implements UzDevid\Conflux\Http\ConfigInterface {
    public function getClient(): ClientInterface {
        return new GuzzleHttp\Client;
    }

    public function getBaseUri(): string {
        return 'https://api.github.com';
    }

    public function getDefaultHeaders(): array {
        return ['Accept' => 'application/json'];
    }
}
```

### 2. Create request class

[](#2-create-request-class)

```
use UzDevid\Conflux\Http\Request\RequestInterface;
use UzDevid\Conflux\Http\Request\RequestQueryInterface;
use UzDevid\Conflux\Http\Request\RequestBodyInterface;
use UzDevid\Conflux\Http\Request\ConvertableBodyInterface;
use UzDevid\Conflux\Http\Request\Method;
use UzDevid\Conflux\Http\Parser\JsonParser;

class GetUser implements RequestInterface, RequestQueryInterface, ConvertableBodyInterface {
    use JsonParser;

    public function getMethod(): Method {
        return Method::GET;
    }

    public function getUrl(): string {
        return '/users/{id}';
    }

    public function getQueryParams(): array {
        return [];
    }

    public function getQueryPath(): array {
        return ['{id}' => 123];
    }

    public function convert(array $response): UserDto {
        return new UserDto($response);
    }
}
```

### 3. Send request

[](#3-send-request)

```
use UzDevid\Conflux\Http\ConfluxHttp;
use \Yiisoft\EventDispatcher\Dispatcher\Dispatcher;

$config = new GithubConfig();
$conflux = new ConfluxHttp($config, new RequestHandler(), new Dispatcher();
$response = $conflux->withRequest(new GetUser())->send(); // UserDto
```

---

Implemented request interfaces
------------------------------

[](#implemented-request-interfaces)

### RequestInterface

[](#requestinterface)

Mandatory interface, sets the method, path and parser answer:

```
interface RequestInterface {
    public function getMethod(): Method|string;
    public function getUrl(): string;
    public function parse(string $content): array;
}
```

> You can use trait `Uzdevid\Conflux\Http\Parser\JsonParser` to pars the answers in JSON format

### RequestQueryInterface

[](#requestqueryinterface)

If you need to send the query parameters or specify them to the URL:

```
interface RequestQueryInterface {
    public function getQueryParams(): array;
    public function getQueryPath(): array;
}
```

### RequestBodyInterface

[](#requestbodyinterface)

If you need send body (`POST`, `PUT` etc.):

```
interface RequestBodyInterface {
    public function getOption(): Option; // Например, 'json', 'form_params'
    public function getBody(): array|string;
}
```

### RequestHeadersInterface

[](#requestheadersinterface)

Custom headers:

```
interface RequestHeadersInterface {
    public function getHeaders(): array;
}
```

### ConvertableBodyInterface

[](#convertablebodyinterface)

If after parsing the body needs to be converted into an object:

```
interface ConvertableBodyInterface {
    public function convert(array $response): mixed;
}
```

---

Example with POST request and body:
-----------------------------------

[](#example-with-post-request-and-body)

```
class CreateUser implements RequestInterface, RequestBodyInterface {
    use JsonParser;

    public function getMethod(): Method {
        return Method::POST;
    }

    public function getUrl(): string {
        return '/users';
    }

    public function getOption(): Option|string {
        return 'json';
    }

    public function getBody(): array|string {
        return ['name' => 'John', 'email' => 'john@example.com'];
    }
}
```

---

### URL replacement

[](#url-replacement)

If the `getUrl()` contains the placeholders `{}`, they will be automatically replaced by values from `getQueryPath()`.

```
getUrl(): '/users/{id}'
getQueryPath(): ['{id}' => 5]

```

Result: `GET /users/5`

---

Handle events
-------------

[](#handle-events)

You can subscribe to the events of `BeforeRequest`, `AfterRequest` and `OnThrow` using the `EventDispatcherInterface` from the package [yiisoft/event-dispatcher](https://github.com/yiisoft/event-dispatcher)

---

If you have suggestions or features, open it issue or write Pull Request ✨

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance48

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~5 days

Total

5

Last Release

384d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104216283?v=4)[UzDevid](/maintainers/uzdevid)[@uzdevid](https://github.com/uzdevid)

---

Top Contributors

[![DikoIbragimov](https://avatars.githubusercontent.com/u/167644693?v=4)](https://github.com/DikoIbragimov "DikoIbragimov (11 commits)")

---

Tags

phphttp clienthttp api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uzdevid-conflux-http/health.svg)

```
[![Health](https://phpackages.com/badges/uzdevid-conflux-http/health.svg)](https://phpackages.com/packages/uzdevid-conflux-http)
```

###  Alternatives

[butschster/kraken-api-client

The most powerful and extendable REST API / Websocket client for Kraken.com. Built on PHP8.0

4914.3k](/packages/butschster-kraken-api-client)[iivannov/branchio

Branch Metrics (Branch.io) HTTP API client

1682.2k](/packages/iivannov-branchio)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)

PHPackages © 2026

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