arkste/hetzner-cloud-client-php

This package is abandoned and no longer maintained. The author suggests using the lkdevelopment/hetzner-cloud-php-sdk package instead.

Hetzner Cloud Client in PHP

v1.0.2 2018-07-17 19:11 UTC

This package is not auto-updated.

Last update: 2020-04-12 19:16:47 UTC


README

Please use https://github.com/LKDevelopment/hetzner-cloud-php-sdk instead!

A PHP wrapper to be used with Hetzner Cloud API.

Scrutinizer Code Quality Code Coverage Build Status Build Status StyleCI Latest Stable Version Total Downloads

A simple wrapper for the Hetzner Cloud API in PHP.

Features

  • Light and fast thanks to lazy loading of API classes
  • Extensively tested

Requirements

Installation

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.

Basic usage of hetzner-cloud-client-php client

<?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.

Example with Pager

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');

Versioning

Version Hetzner Cloud API Version
1.x V1

Why no PHP 7.0 Features?

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.

License

hetzner-cloud-client-php is licensed under the MIT License - see the LICENSE file for details

Credits

This Library is heavily inspired by php-github-api & php-gitlab-api.

Thanks to Hetzner for the high quality API and documentation.