PHPackages                             anomalyce/interlocutor - 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. anomalyce/interlocutor

ActiveLibrary[API Development](/categories/api)

anomalyce/interlocutor
======================

v1.1.0(3y ago)0129MITPHPPHP ^8.1

Since Feb 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/anomalyce/interlocutor)[ Packagist](https://packagist.org/packages/anomalyce/interlocutor)[ RSS](/packages/anomalyce-interlocutor/feed)WikiDiscussions main Synced 1w ago

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

Interlocutor
============

[](#interlocutor)

A HTTP wrapper that keeps your API integrations well organised.

```
composer require anomalyce/interlocutor
```

Concepts
--------

[](#concepts)

Before we start looking at some code, it is important to understand a few core concepts behind this package...

#### Engines

[](#engines)

The Interlocutor package doesn't actually send any HTTP requests on its own, but rather relies on an underlying HTTP client (or engine) to do so. You may easily create an implementation for your favourite HTTP client by making sure it implements the `\Anomalyce\Interlocutor\Contracts\Engine` interface.

By default, the Interlocutor package provides a simple [Guzzle](https://github.com/guzzle/guzzle) engine implementation. While this is provided out-of-the-box, you must manually decide to install the `guzzlehttp/guzzle` Composer package should you intend to use it.

#### Endpoints

[](#endpoints)

The Interlocutor package is built on the idea that every API endpoint that you are intending on interacting with, should have its very own dedicated endpoint class (implementing the `\Anomalyce\Interlocutor\Contracts\Endpoint` interface).

Not only does this give you the benefit of having everything related to that API endpoint in one location, but it also makes it a breeze to use the same request in multiple locations across your application.

In summary, an endpoint class contains all the required information needed to make the request. The HTTP verb, the endpoint URL, the data and the headers it requires. It also allows you to easily make modifications to the request object (as assembled by the engine), transform the response or handle any exceptions that may be thrown.

#### Drivers

[](#drivers)

If you're working against any sizable API, you're more likely than not interacting with more than just a couple of endpoints, which means that you're all of a sudden repeating a bunch of code for each endpoint...

This is where drivers come into the picture. A driver (implementing the `\Anomalyce\Interlocutor\Contracts\Driver` interface) is basically a way of doing all of the repetitive tasks in one place (e.g. specifying the base URL, setting common headers, API credentials, parsing the response using `json_decode()` etc.).

All of the data specified by an in-use driver gets passed down from its driver method to the respective endpoint method as their argument. The only exception, no pun intended, is the `handleExceptions` method which is endpoint first, driver last. It is then up to the endpoint on how to proceed with this information (merging, overriding or ignoring).

Usage
-----

[](#usage)

In our examples below, we'll use the provided out-of-the-box engine for Guzzle, and thus must also install the Guzzle HTTP library.

```
composer require guzzlehttp/guzzle
```

Next up we need to create our Interlocutor object. This should only have to be done once across your application, for most use cases anyway. Place it wherever it makes sense in your application (e.g. in a service provider).

```
use Anomalyce\Interlocutor\{ Engines, Interlocutor };

$interlocutor = new Interlocutor(
  new Engines\GuzzleHttp
);
```

That's really all you have to do as far as setup goes. It is now time to create your endpoints and/or drivers, but seeing as that heavily relies on how the API itself looks, I'll simply refer you to our examples and various interfaces listed further down.

Once you've got your endpoint objects all set up, you may go ahead and send the request in two different ways. Either, you pass it to the `$interlocutor` object's `send` method, like so...

```
$request = new \Example\Vendor\MyEndpoint('passing-data-here');

$response = $interlocutor->send($request);

print_r($response);
```

Or, you can utilise the `\Anomalyce\Interlocutor\Interlocutory` trait within your endpoint classes to have them be self-sending. I'll let you decide whichever way suits you and your application best.

```
// class MyEndpoint implements \Anomalyce\Interlocutor\Contracts\Endpoint {
//   use \Anomalyce\Interlocutor\Interlocutory;
// }

$request = new \Example\Vendor\MyEndpoint('passing-data-here');

$response = $request->send();

print_r($response);
```

References
----------

[](#references)

#### Interfaces

[](#interfaces)

- [`\Anomalyce\Interlocutor\Contracts\Engine`](src/Contracts/Engine.php)
- [`\Anomalyce\Interlocutor\Contracts\Endpoints`](src/Contracts/Endpoints.php)
- [`\Anomalyce\Interlocutor\Contracts\Driver`](src/Contracts/Driver.php)

#### Examples

[](#examples)

- [JsonPlaceholder](examples/JsonPlaceholder)
- [WHMCS](examples/WHMCS/)
- [FreeIpApi](examples/FreeIpApi/)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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

Total

3

Last Release

1440d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/27ae6ce669e8caec5962dd549c7d72e6a095ca9ecdc0324200d18660c5e8b345?d=identicon)[Anomalyce](/maintainers/Anomalyce)

---

Top Contributors

[![anomalyce](https://avatars.githubusercontent.com/u/47085833?v=4)](https://github.com/anomalyce "anomalyce (18 commits)")

---

Tags

apihttpphp

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/anomalyce-interlocutor/health.svg)

```
[![Health](https://phpackages.com/badges/anomalyce-interlocutor/health.svg)](https://phpackages.com/packages/anomalyce-interlocutor)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)[php-heroku-client/php-heroku-client

A PHP client for the Heroku Platform API

24404.8k4](/packages/php-heroku-client-php-heroku-client)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

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

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)[brd6/notion-sdk-php

Notion SDK for PHP

5918.0k](/packages/brd6-notion-sdk-php)

PHPackages © 2026

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