PHP Bindings
Introduction
This is an introduction to the Gear6 PHP API language bindings. The API allows users to remotely control a Gear6 Web Cache Appliance from within their own applications.
The API employs a REST-like interface to pass XML records to and from the configuration database of the Web Cache Appliance via an authenticated HTTP or HTTPS POST.
License
The PHP API language bindings are provided under a BSD license to allow easy integration into customer applications.
The full license can be viewed here.
Requirements
The following language binding requires PHP 5.2 or newer as well as the following modules compiled in:
- SimpleXML
Download
Available versions of the PHP language bindings:
PHP bindings Version 0.2
Example
Below is a basic example of how to use the PHP language bindings. It shows how to connect to a Web Cache Appliance, get a list of memcached services, print out the names, and change the memcached package to Gear6's memcached package.
/* Example Code */
require_once('g6Appliance.php');
error_reporting(E_ALL ^ E_USER_NOTICE);
/* URI Format: $proto://$user:$password@$host:$port */
$uri = 'http://admin@webcache01';
/* Instantiate new g6Appliance class. */
$g6 = new g6Appliance($uri, API_MODE_PASSIVE);
/* Verify that the class is able to authenticate against the appliance */
if ($g6->authenticate() == FALSE) {
echo('Error tring to authenticate with ' . $uri . "n");
exit(1);
}
/* Get array of memcache services */
$services = $g6->getMemcacheServices();
foreach ($services as $service) {
echo('Service: ' . $service->getName() . "n")
/* Change the memcache package to the Gear6 version */
$service->setPackage('memcached-gear6');
/* Check to see if API is in passive mode, if so submit changes */
if ($g6->getOption(OPTION_API_MODE) == API_MODE_PASSIVE)) {
$service->submit();
}
}
