A PHP implementation of an Hipache client

1.0.0 2015-05-08 13:59 UTC

This package is auto-updated.

Last update: 2022-04-29 00:41:32 UTC


Scrutinizer Code Quality

This library is an Hipache PHP client.


Use Composer to install this library as dependency:

composer require sroze/hipache-client


Usage is made to be quite simple and can be done though the Client object endpoint.

Create a client

This Client class should be created with an adapter, because Hipchat supports multiple adapters (called drivers). See the adapters section to how instanciate an adapter.

use Hipache\Client;

$client = new Client($adapter);

List all frontends

Just call the getFrontendCollection method to have a traversable collection of frontends:

$frontendCollection = $client->getFrontendCollection();

foreach ($frontendCollection as $frontend) {
    echo $frontend->getHostname();

Create a frontend

There's a createFrontend method on the client that allows you to create a frontend:

use Hipache\Frontend\Frontend;
use Hipache\Frontend\Exception\FrontendAlreadyExists;

try {
    $frontend = $client->createFrontend(new Frontend(''));
} catch (FrontendAlreadyExists $e) {
    // Given frontend can't be created since it already exists...

Get a frontend by its domain name

There's a getFrontend method that returns a Frontend object based on its name.

use Hipache\Frontend\Exception\FrontendNotFound;

try {
    $frontend = $client->getFrontend('');
} catch (FrontendNotFound $e) {
    // Frontend was not found...

Updating frontends' backends

When you've fetched a frontend with the Client class, you have a WritableFrontend instance. That means that you just have to call one of the add or remove methods to respectively add or remove a backend from it.

Here's an example how to add 2 backends to a given frontend:

use Hipache\Backend\Backend;

$frontend = $client->getFrontend('');
$frontend->add(new Backend(''));
$frontend->add(new Backend(''));

If you want to remove backends, just add the remove method:

$frontend = $client->getFrontend('');
$frontend->remove(new Backend(''));


There's right know only the Redis adapter (recommended one) that is supported.

Redis adapter

The RedisAdapter class needs to be constructed with a configured Predis client, and that's all.

Here's an example how to create an instance of a Redis adapter:

use Predis\Client as RedisClient;
use Hipache\Adapter\RedisAdapter;

$adapter = new RedisAdapter(new RedisClient('tcp://'));