hnhdigital-os/php-linode-api

The v4 Linode API for PHP [BETA].

1.0.0-alpha 2018-05-20 13:21 UTC

This package is auto-updated.

Last update: 2024-03-22 00:19:13 UTC


README

 _     _                 _       ___  ______ _____
| |   (_)               | |     / _ \ | ___ \_   _|
| |    _ _ __   ___   __| | ___/ /_\ \| |_/ / | |
| |   | | '_ \ / _ \ / _` |/ _ \  _  ||  __/  | |
| |___| | | | | (_) | (_| |  __/ | | || |    _| |_
\_____/_|_| |_|\___/ \__,_|\___\_| |_/\_|    \___/

The v4.01 Linode API for PHP [BETA].

#f03c15 Definately a work in progress. Do not use.

Latest Stable Version Total Downloads Latest Unstable Version License Donate to this project using Patreon

Build Status StyleCI Test Coverage Issue Count Code Climate

This package has been developed by H&H|Digital, an Australian botique developer. Visit us at hnh.digital.

This package is built automatically using the OpenAPI specification for the Linode v4 API.

Documentation

Requirements

  • PHP 7.1+

Install

Via composer:

$ composer require hnhdigital-os/php-linode-api dev-master

Examples

Regions

Results returned from any search based endpoint are provided as an instance of that type. This allows you to call any endpoints immediately.

Results from the get method are returned as an object that implements Iterator and Countable, allowing you to use this in a foreach and to use count. Linode limits search results to 25 records per page - this is overcome by automatically requesting the next page of records when the last record is reached in the current page.

foreach ((new Regions())->get() as $region) {
    // Do something with the region data (returned as an instance of Region)
}

Calling the all method automatically loads every page of results.

$regions = (new Regions())->get()->all();

Region

You can get a specific record, simply by creating the object with the required parameters. This will automatically call the endpoint and return the object ready to use. The record will auto-load by setting the last parameter to true.

$region = new Region('us-east-1a', true);

echo $region->id.' ('.$region->country.')';
us-east-1a (US)

Calling the get method directly on this same class will return an array of the values from the same endpoint. This will also auto-fill the object (the same as above, passing the true actually just calls the get method).

$result = (new Region('us-east-1a'))->get();

print_r($result);
Array
(
    [id] => us-east-1a
    [country] => US
)

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.