A PHP wrapper to be used with Hetzner Cloud API.
A simple wrapper for the Hetzner Cloud API in PHP.
- Light and fast thanks to lazy loading of API classes
- Extensively tested
- PHP >= 5.5.9
- A HTTP client
- A PSR-7 implementation
- (optional) PHPUnit to run tests.
via composer
composer require arkste/hetzner-cloud-client-php php-http/guzzle6-adapter
Why php-http/guzzle6-adapter
? We are decoupled from any HTTP messaging client with help by HTTPlug.
You can visit HTTPlug for library users to get more information about installing HTTPlug related packages.
<?php
use HetznerCloud\HttpClient\Message\ResponseMediator;
// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';
// Create Client and authenticate with your token
$client = \HetznerCloud\Client::create()
->authenticate('YOUR_API_TOKEN')
;
// Get all Servers
$servers = $client->servers()->all();
// Get additional information about the last Response
$lastResponse = $client->getLastResponse();
$pagination = ResponseMediator::getPagination($lastResponse);
$apiLimit = ResponseMediator::getApiLimit($lastResponse);
From $client
object, you can access to all Hetzner Cloud.
to fetch all actions with pagination:
<?php
// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';
// Create Client and authenticate with your token
$client = \HetznerCloud\Client::create()
->authenticate('YOUR_API_TOKEN')
;
// Create ResultPager with Client
$pager = new \HetznerCloud\ResultPager($client);
// Get all Actions
$actions = $pager->fetchAll($client->actions(), 'all');
Version | Hetzner Cloud API Version |
---|---|
1.x | V1 |
This Library aims to be as compatible as possible, thats why it only needs PHP >= 5.5.9 and depends on very few composer packages.
hetzner-cloud-client-php
is licensed under the MIT License - see the LICENSE file for details
This Library is heavily inspired by php-github-api & php-gitlab-api.
Thanks to Hetzner for the high quality API and documentation.