Download the PHP package anomalyce/interlocutor without Composer

On this page you can find all versions of the php package anomalyce/interlocutor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package interlocutor

Interlocutor

A HTTP wrapper that keeps your API integrations well organised.


Concepts

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

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 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

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

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

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.

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).

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...

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.


References

Interfaces

Examples


All versions of interlocutor with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/pipeline Version ^9.1.0
psr/http-message Version ^1.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package anomalyce/interlocutor contains the following files

Loading the files please wait ....