2017 © Pedro Peláez
 

library hipache-client

A PHP implementation of an Hipache client

image

sroze/hipache-client

A PHP implementation of an Hipache client

  • Friday, May 8, 2015
  • by sroze
  • Repository
  • 1 Watchers
  • 4 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Hipache Client

Scrutinizer Code Quality, (*1)

This library is an Hipache PHP client., (*2)

Installation

Use Composer to install this library as dependency:, (*3)

composer require sroze/hipache-client

Usage

Usage is made to be quite simple and can be done though the Client object endpoint., (*4)

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., (*5)

use Hipache\Client;

$client = new Client($adapter);

List all frontends

Just call the getFrontendCollection method to have a traversable collection of frontends:, (*6)

$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:, (*7)

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

try {
    $frontend = $client->createFrontend(new Frontend('www.example.com'));
} 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., (*8)

use Hipache\Frontend\Exception\FrontendNotFound;

try {
    $frontend = $client->getFrontend('www.example.com');
} 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., (*9)

Here's an example how to add 2 backends to a given frontend:, (*10)

use Hipache\Backend\Backend;

$frontend = $client->getFrontend('sroze.io');
$frontend->add(new Backend('http://1.2.3.4:8000'));
$frontend->add(new Backend('http://1.2.3.4:8001'));

If you want to remove backends, just add the remove method:, (*11)

$frontend = $client->getFrontend('sroze.io');
$frontend->remove(new Backend('http://1.2.3.4:8000'));

Adapters

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

Redis adapter

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

Here's an example how to create an instance of a Redis adapter:, (*14)

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

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

The Versions

08/05 2015

dev-master

9999999-dev https://github.com/sroze/HipacheClient

A PHP implementation of an Hipache client

  Sources   Download

MIT

The Requires

 

The Development Requires

client hipache

08/05 2015

1.0.0

1.0.0.0 https://github.com/sroze/HipacheClient

A PHP implementation of an Hipache client

  Sources   Download

MIT

The Requires

 

The Development Requires

client hipache