We have an official PHP wrapper for working with the Server Density API on GitHub.
Getting Started
Download composer in the working/development directory:
curl -s http://getcomposer.org/installer | php
Create a file named composer.json
and add the following code to it
{
"require": {
"serverdensity/sd-api-wrapper": ">=0.7.4"
}
}
Install the wrapper and required dependancies:
php composer.phar install
The PHP wrapper is now ready to use - you'll need to include vendor/autoload.php
and instantiate the class. Use the following code as an example.
<?php
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;
$client = new Client();
$client->authenticate('auth_token_here');
// A basic call to view devices
$devices = $client->api('devices')->all();
The following verbs exist:
create
- creating a resource, takes an arraydelete
- deleting a resource, takes an IDview
- viewing a single resource, taken an IDall
- view all resourcesupdate
- updating a resource, takes fields that needs updatingsearch
(for some endpoints)
Examples
We have an example of using the PHP wrapper to retrieve and graph metrics.
The PHP wrapper is fully supported so if you have any queries or comments just email hello@serverdensity.com or submit a ticket.
Comments