API PHP wrapper

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 array
  • delete - deleting a resource, takes an ID
  • view - viewing a single resource, taken an ID
  • all - view all resources
  • update - updating a resource, takes fields that needs updating
  • search (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.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.