PHPackages                             bbc/ipr-webservicekit - 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. bbc/ipr-webservicekit

ActiveLibrary[API Development](/categories/api)

bbc/ipr-webservicekit
=====================

Webservice reading layer library

v2.0(8y ago)13.3k2MITPHPPHP &gt;=5.6

Since Aug 11Pushed 8y ago50 watchersCompare

[ Source](https://github.com/bbc/ipr-php-webservicekit)[ Packagist](https://packagist.org/packages/bbc/ipr-webservicekit)[ RSS](/packages/bbc-ipr-webservicekit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (25)Used By (0)

BBC\\iPlayerRadio\\WebserviceKit
================================

[](#bbciplayerradiowebservicekit)

A powerful layer for reading data from webservices in a fast, extendable and resilient way.

[![Build Status](https://camo.githubusercontent.com/4b6b397b9783561b954316532ef5b63e8949214313d693b7086cc52167172fe5/68747470733a2f2f7472617669732d63692e6f72672f6262632f6970722d7068702d776562736572766963656b69742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bbc/ipr-php-webservicekit)[![Latest Stable Version](https://camo.githubusercontent.com/07e9fb3984c9c74c58468600cdf6177186199b7d6240961807d9c4248d1791a8/68747470733a2f2f706f7365722e707567782e6f72672f6262632f6970722d776562736572766963656b69742f762f737461626c652e737667)](https://packagist.org/packages/bbc/ipr-webservicekit)[![Total Downloads](https://camo.githubusercontent.com/03174a46d45966bbc38778ab7fabf01e8e6e45afb6b6fc245c52de9274fbb393/68747470733a2f2f706f7365722e707567782e6f72672f6262632f6970722d776562736572766963656b69742f646f776e6c6f6164732e737667)](https://packagist.org/packages/bbc/ipr-webservicekit)[![License](https://camo.githubusercontent.com/cfab68542fd5df471e79bba270be13c478d2c8d181eb4cd8c34fa94c73916346/68747470733a2f2f706f7365722e707567782e6f72672f6262632f6970722d776562736572766963656b69742f6c6963656e73652e737667)](https://packagist.org/packages/bbc/ipr-webservicekit)

- [Requirements](#requirements)
- [Features](#features)
- [Background](#background)
- [Basic Usage](#basic-usage)
- [Documentation](#documentation)

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

[](#requirements)

- PHP &gt;= 5.6

Features
--------

[](#features)

- Resilient, stale-while-revalidate caching at the core
- Full monitoring and logging hooks
- Lightweight (usually a single class) integration of webservices
- Variable cURL timeouts based on cache state
- Multi-curl requests
- Circuit breaker protection for backends
- Framework agnostic
- Highly tested and battle-proven
- Unit testing helper traits to simplify mocking webservices

Background
----------

[](#background)

This library makes it easy to read data from RESTful or HTTP based APIs, be they public, API key gated or via SSL certificates.

To integrate a new backend, the library consumer simply needs to create a class that implements `BBC\iPlayerRadio\WebserviceKit\QueryInterface` (you can even just subclass the `BBC\iPlayerRadio\WebserviceKit\Query` class that covers most of the essentials!)

These queries tell WebserviceKit how to communicate with the backend service, how to cache it and what to do with the responses it receives.

Basic Usage
-----------

[](#basic-usage)

You will only need a single instance of WebserviceKit within your app, which you then pass Query's into.

```
$client = new GuzzleHttp\Client();
$cache = new BBC\iPlayerRadio\Cache\Cache(new RedisCache());

$service = new BBC\iPlayerRadio\WebserviceKit\Service(
    $client,
    $cache
);
```

You can then define Query classes:

```
