2017 © Pedro Peláez
 

library cloudstack

Cloudstack PHP Client

image

pcextreme/cloudstack

Cloudstack PHP Client

  • Tuesday, June 26, 2018
  • by kevindierkx
  • Repository
  • 5 Watchers
  • 5 Stars
  • 3,337 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 14 Versions
  • 24 % Grown

The README.md

github-readme_header, (*1)

PHP Cloudstack Client

Latest Version Software License Build Status Scrutinizer Coverage Status, (*2)

This package makes it simple to integrate the Cloudstack API in your PHP applications., (*3)

Requirements

The following versions of PHP are supported:, (*4)

  • PHP 7.1 or higher

Support for PHP 5.x has been dropped

In favour of stricter type hinting and return types we stopped supporting older PHP versions in new releases., (*5)

Please note: General support for PHP 5.x will be ending soon, check the PHP documentation for more information about PHP version support., (*6)

If you still require support for PHP 5.x or HHVM you can use the ~0.2 releases of this package., (*7)

Installation

Use composer require to add the client to your composer.json file, please check the Composer documentation for more information about Composer., (*8)

$ composer require pcextreme/cloudstack

Usage

There are various ways to interact with the Cloudstack API using this package. The easiest and preferred way is to call the Cloudstack 'commands' directly as a method on the client., (*9)

Internally the client resolves the command using the __call magic method. The command will be automatically resolved and the provided options are verified. Also when everything goes as expected the API response is automatically parsed., (*10)

The client uses an API list mapping stored in the cache folder do determine if an API command exists and all required parameters are provided. This list is generated using Cloudstack's listApis command., (*11)

<?php

include(__DIR__.'/vendor/autoload.php');

use PCextreme\Cloudstack\Client;

$client = new Client([
    'urlApi'    => 'https://api.auroracompute.eu/ams',
    'apiKey'    => 'YOUR-API-KEY',
    'secretKey' => 'YOUR-SECRET-KEY',
]);

var_dump($client->listAccounts(['name' => 'admin', 'listall' => 'true']));

Directly calling the command method

Its also possible to bypass the __call magic method and call the command method directly., (*12)

<?php

// Using an existing client instance.

$client->command('listAccounts', ['name' => 'admin', 'listall' => 'true']);

Manually accessing the API

If for some reason the cache/api_list.php is removed, outdated or gets corrupted you can access the API directly by building a request manually. This bypasses all previously mentioned checks but still parses the response., (*13)

<?php

// Using an existing client instance.

$command = 'listAccounts';
$options = ['name' => 'admin', 'listall' => 'true'];

$method  = $client->getCommandMethod($command);
$url     = $client->getCommandUrl($command, $options);
$request = $client->getRequest($method, $url, $options);

$accounts = $client->getResponse($request);

Updating the API list

You can update or regenerate the provided API list using the bin/cloudstack CLI., (*14)

$ php bin/cloudstack api:list

You can also get a list of available CLI commands., (*15)

$ php bin/cloudstack

Contributing

This package is open-source and welcomes issues and pull requests from anyone. Before opening pull requests, please read our short Contribution Guide., (*16)

Credits

License

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

The Versions

26/06 2018

dev-master

9999999-dev https://github.com/pcextreme/cloudstack-php

Cloudstack PHP Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Dierkx

php aurora cloudstack pcextreme

26/06 2018
25/06 2018
25/06 2018

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/pcextreme/cloudstack-php

Cloudstack PHP Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Dierkx

php aurora cloudstack pcextreme

24/06 2018
04/06 2018
17/05 2018
11/12 2017
07/02 2017
06/02 2017
26/01 2017
23/01 2017
21/12 2016
18/08 2016

0.1.0

0.1.0.0 https://github.com/pcextreme/cloudstack-php

Cloudstack PHP Client

  Sources   Download

MIT

The Requires

 

by Kevin Dierkx

php aurora cloudstack pcextreme