PHP code example of sroze / hipache-client

1. Go to this page and download the library: Download sroze/hipache-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sroze / hipache-client example snippets


use Hipache\Client;

$client = new Client($adapter);

$frontendCollection = $client->getFrontendCollection();

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

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

use Hipache\Frontend\Exception\FrontendNotFound;

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

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'));

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

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

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