PHPackages                             slepic/http-transfer - 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. slepic/http-transfer

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

slepic/http-transfer
====================

Simple PHP library working with PSR HTTP message transfers.

1.0.1(2mo ago)120.3k3BSD-3-ClausePHPPHP &gt;=8.0CI failing

Since May 3Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/slepic/http-transfer)[ Packagist](https://packagist.org/packages/slepic/http-transfer)[ RSS](/packages/slepic-http-transfer/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (6)Versions (5)Used By (3)

[![Build Status](https://camo.githubusercontent.com/845ec305d000f44344b114e2ff9241a4213375f2a82c41139219ec63c31f5d94/68747470733a2f2f7472617669732d63692e6f72672f736c657069632f687474702d7472616e736665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/slepic/http-transfer)[![Style Status](https://camo.githubusercontent.com/4a4e38fce33de36aacef86cc9d43c2d8f01e486e0b0794058bfb7cffa7fcd6ba/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138343431363237372f736869656c64)](https://styleci.io/repos/184416277)

http-transfer
=============

[](#http-transfer)

Simple PHP library working with PSR HTTP message transfers.

Usage
-----

[](#usage)

There are 3 components at this moment:

### Log

[](#log)

This component consists of:

- interface [`Slepic\Http\Transfer\Log\LogInterface`](https://github.com/slepic/http-transfer/blob/master/src/Log/LogInterface.php) defining a simple structure holing the request, response, error, time of start and end of the transfer.
    - and its implementation [`Slepic\Http\Transfer\Log\Log`](https://github.com/slepic/http-transfer/blob/master/src/Log/Log.php)
- interface [`Slepic\Http\Transfer\Log\StorageInterface`](https://github.com/slepic/http-transfer/blob/master/src/Log/StorageInterface.php) which is used to store the logs.
    - and of course its simple implementation [`Slepic\Http\Transfer\Log\ArrayStorage`](https://github.com/slepic/http-transfer/blob/master/src/Log/ArrayStorage.php) which stores the logs in array.

```
$storage = new ArrayStorage();
$storage->store(new Log($request, $start, $end, $response, $exception, $context));
assert($storage[0]->getRequest() === $request);
assert($storage[0]->getResponse() === $response);
assert($storage[0]->getException() === $exception);
assert($storage[0]->getStartTime() === $start);
assert($storage[0]->getEndTime() === $end);
assert($storage[0]->getContext() === $context);

```

### Observer

[](#observer)

An abstraction over the transfer process where the observer is notified about start and end of transfer processes.

The observation is provided by the [`Slepic\Http\Transfer\Observer\ObserverInterface`](https://github.com/slepic/http-transfer/blob/master/src/Observer/ObserverInterface.php) which is in fact just a factory.

The observer takes the initiating request and returns a one use object implementing [`Slepic\Http\Transfer\Observer\ObserverDelegateInterface`](https://github.com/slepic/http-transfer/blob/master/src/Observer/ObserverDelegateInterface.php).

The delegate is destined to be notified of either success or failure of the transfer, and then it gets destroyed by garbage collector.

```
$observer = new SomeImplementationOfObserverInterface();
$delegate = $observer->observe($request, $context);

//process the $request
//...
//got $response ...

$delegate->success($response);

//or maybe got network exception
$delegate->error($exception);

//or maybe some client like guzzle throw exceptions for HTTP 4xx and 5xx when the response object exists along the exception
$delegate->error($exception, $exception instanceof GuzzleException ? $exception->getResponse() : null);

```

### History

[](#history)

A coposition of the two above that implements the osbserver to create the logs with duration information.

This one contains just an implementation of the [`Slepic\Http\Transfer\Observer\ObserverInterface`](https://github.com/slepic/http-transfer/blob/master/src/Observer/ObserverInterface.php).

The [`Slepic\Http\Transfer\History\HistoryObserver`](https://github.com/slepic/http-transfer/blob/master/src/History/HistoryObserver.php) pushes transfer logs to a storage as they get completed.

Well of course the job is actualy done by its delegate [`Slepic\Http\Transfer\History\HistoryObserverDelegate`](https://github.com/slepic/http-transfer/blob/master/src/History/HistoryObserverDelegate.php)

```
//create services
$storage = new ArrayStorage();
$observer = new HistoryObserver($storage);

//somewhere you send some requests
foreach ($requests as $request) {his
  $delegate = $observer->observe($request);
  try {
    $response = $client->sendRequest($request);
  } catch (\Exception $e) {
    $delegate->error($e);
    throw $e;
  }
  $delegate->success($response);
}

//and when u need it you can access transfer logs
foreach ($storage as $log) {
  var_dump($log->getRequest());
  var_dump($log->getResponse());
  var_dump($log->getEndTime() - $log->getStartTime());
  //...
}

```

Packagist Providers
-------------------

[](#packagist-providers)

- [`slepic/http-transfer-log-consumer`](https://packagist.org/providers/slepic/http-transfer-log-consumer) - consumers of LogInterface
- [`slepic/http-transfer-observer-consumer`](https://packagist.org/providers/slepic/http-transfer-observer-consumer) - consumers of ObserverInterface and ObserverDelegateInterface
- [`slepic/http-transfer-observer-implementation`](https://packagist.org/providers/slepic/http-transfer-observer-implementation) - implementations of ObserverInterface and ObserverDelegateInterface.

If you use this library in a public project and you use composer and share the project on packagist, consider adding the packagist providers above to your composer.json like this:

```
"provide": {
  "slepic/http-transfer-*-consumer": "*", //if you created a consumer of correspoding interface(s)
  "slepic/http-transfer-*-implementation": "*" //if you created implementation of corresponding interface(s)
},
"suggest": {
  "slepic/http-transfer-*-consumer": "*",  //if you created implementation of corresponding interface(s)
  "slepic/http-transfer-*-implementation": "*" //if you created a consumer of correspoding interface(s)
}

```

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Total

4

Last Release

60d ago

Major Versions

0.1.1 → 1.0.02022-01-07

PHP version history (3 changes)0.1.0PHP ^5.6 || ^7.0

0.1.1PHP &gt;=5.6

1.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5dd1cd12d4fe4974ad1e3609065ac4eb13c29023606c289c08153c432da827cf?d=identicon)[slepic](/maintainers/slepic)

---

Top Contributors

[![slepic](https://avatars.githubusercontent.com/u/8199404?v=4)](https://github.com/slepic "slepic (15 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/slepic-http-transfer/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185702.8k44](/packages/laudis-neo4j-php-client)

PHPackages © 2026

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