PHPackages                             forsaken-threads/diplomatic - 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. forsaken-threads/diplomatic

ActiveLibrary

forsaken-threads/diplomatic
===========================

A diplomatic cURL wrapper.

v1.0.0(3y ago)11.8k↑2900%11MITPHPPHP ^8.0

Since Oct 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/forsaken-threads/diplomatic)[ Packagist](https://packagist.org/packages/forsaken-threads/diplomatic)[ RSS](/packages/forsaken-threads-diplomatic/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (1)Versions (14)Used By (1)

Diplomatic
==========

[](#diplomatic)

### A diplomatic cURL wrapper for API calls

[](#a-diplomatic-curl-wrapper-for-api-calls)

This is a practical, yet sophisticated, HTTP client for making API calls and parsing their responses. Some of the basic features are *Response Handler* dependency injection, callback registration for the three basic response results - errored, failed, and successful - and the ability to print out a CLI version of the underlying cURL call for the ultimate in hands on debugging.

The **Diplomatic** way is to attempt to be discrete at all costs. It should almost never throw an exception. The *Client* safely tucks away all of the ugliness of handling the request and leaves any `Exception` throwing for you to handle, in your own way, in your own time. You extend the `ResponseHandler` class, inject it into the *Client*, and the *Client* will silently collect all of the information it can about the response and pass it on to your handler. What you do with it from there is up to you.

### Installation

[](#installation)

`composer require forsaken-threads/diplomatic`

### Basic Usage

[](#basic-usage)

The simplest usage relies on a default `ResponseHandler` that determines if a request was successful by looking at the HTTP status code of the response: a 2XX code is successful, a 5XX code is errored, and anything else is failed. Check it out [here](./src/BasicHandler.php).

```
