2017 © Pedro Peláez
 

library linode-api-php

Linode API v3 Client Library for PHP

image

arodygin/linode-api-php

Linode API v3 Client Library for PHP

  • Wednesday, March 1, 2017
  • by webinarium
  • Repository
  • 4 Watchers
  • 23 Stars
  • 1,220 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 15 Versions
  • 2 % Grown

The README.md

PHP Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality, (*1)

Linode API v3 Client Library for PHP

This library implements full spec of Linode API v3 (in accordance with https://www.linode.com/api/utility/api.spec), including functions which are not described at the Linode's site yet (the documentation seems to be slightly outdated at the moment)., (*2)

The library wasn't actually implemented, but autogenerated from the spec. This approach provides several advantages as: * we can be sure that nothing from the spec is missed, * no implementation errors which could be caused by human factor, * in case of the spec extension it's fast and easy to update the library's code., (*3)

Also please note that "test.echo" is skipped from the implementation., (*4)

Warning

The library addresses Linode's legacy API. For most recent API please refer to this library., (*5)

Requirements

PHP needs to be a minimum version of PHP 5.6., (*6)

Installation

The recommended way to install is via Composer:, (*7)

composer require "webinarium/linode-api3"

Usage Example

Below is a complete example of how to create a new Linode host using the library:, (*8)

use Linode\LinodeApi;
use Linode\LinodeException;
use Linode\PaymentTerm;

// Your API key from the Linode profile.
$key = '...';

// Hardcode some IDs to make the example shorter.
// Normally you might want to use "Linode\AvailApi" class functions.
$datacenter = 3;    // Fremont datacenter
$plan       = 1;    // we will use the cheapest plan

// Create new linode.
try {
    $api = new LinodeApi($key);
    $res = $api->create($datacenter, $plan, PaymentTerm::ONE_MONTH);

    printf("Linode #%d has been created.\n", $res['LinodeID']);
}
catch (LinodeException $e) {
    printf("Error #%d: %s.\n", $e->getCode(), $e->getMessage());
}

Batching Requests

The Linode API also supports a batched mode, whereby you supply multiple request sets and receive back an array of responses. Example batch request using the library:, (*9)

use Linode\Batch;
use Linode\LinodeApi;
use Linode\PaymentTerm;

// Your API key from the Linode profile.
$key = '...';

// Hardcode some IDs to make the example shorter.
// Normally you might want to use "Linode\AvailApi" class functions.
$datacenters = [2, 3, 4, 6];    // all four US datacenters
$plan        = 1;               // we will use the cheapest plan

// Create a batch.
$batch = new Batch($key);

// Create new linode on each of US datacenters.
$api = new LinodeApi($batch);

foreach ($datacenters as $datacenter) {
    $api->create($datacenter, $plan, PaymentTerm::ONE_MONTH);
}

// Execute batch.
$results = $batch->execute();

foreach ($results as $res) {
    printf("Linode #%d has been created.\n", $res['DATA']['LinodeID']);
}

Tests

Almost all tests are mocked so you don't have to use a real API key and no real linodes are affected. The only tests which make a complete API call are TestTest (for "test.echo") and ApiTest (for "api.spec"):, (*10)

./bin/phpunit --coverage-text

Library regeneration

If you would like to regenerate the library code, you can do it with two simple steps:, (*11)

php ./generator/generator
php ./bin/php-cs-fixer fix

The Versions

01/03 2017

dev-master

9999999-dev https://github.com/arodygin/php-linode-api3

Linode API v3 Client Library for PHP

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.4.0

 

The Development Requires

api linode

30/12 2016

1.1.10

1.1.10.0 https://github.com/arodygin/php-linode-api3

Linode API v3 Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

26/10 2016

1.1.9

1.1.9.0 https://github.com/arodygin/php-linode-api3

Linode API v3 Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

28/07 2016

1.1.8

1.1.8.0 https://github.com/arodygin/php-linode-api3

Linode API v3 Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

31/05 2016

1.1.7

1.1.7.0 https://github.com/arodygin/linode-api-php

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

01/05 2016

1.1.6

1.1.6.0 https://github.com/arodygin/linode-api-php

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

28/02 2016

1.1.5

1.1.5.0 https://github.com/arodygin/linode-api-php

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

28/09 2015

1.1.4

1.1.4.0

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2.0
  • ext-curl *
  • ext-json *

 

The Development Requires

api linode

20/08 2015

1.1.3

1.1.3.0

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php ~5.2

 

The Development Requires

api linode

13/07 2015

1.1.2

1.1.2.0

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php ~5.2

 

The Development Requires

api linode

02/07 2015

1.1.1

1.1.1.0

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php ~5.2

 

The Development Requires

api linode

22/06 2015

1.1.0

1.1.0.0

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

The Development Requires

api linode

09/02 2015

1.0.2

1.0.2.0

Linode API Client Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

The Development Requires

api linode

03/02 2015

1.0.1

1.0.1.0

Linode API Client Library for PHP

  Sources   Download

GPL-3.0

The Requires

  • php >=5.2.0

 

The Development Requires

16/01 2015

1.0.0

1.0.0.0

Linode API Client Library for PHP

  Sources   Download

GPL-3.0

The Requires

  • php >=5.2.0