_ _ _ ___ ______ _____
| | (_) | | / _ \ | ___ \_ _|
| | _ _ __ ___ __| | ___/ /_\ \| |_/ / | |
| | | | '_ \ / _ \ / _` |/ _ \ _ || __/ | |
| |___| | | | | (_) | (_| | __/ | | || | _| |_
\_____/_|_| |_|\___/ \__,_|\___\_| |_/\_| \___/
The v4.01 Linode API for PHP [BETA].
Definately a work in progress. Do not use.
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.
- PHP 7.1+
Via composer:
$ composer require hnhdigital-os/php-linode-api dev-master
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();
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
)
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.