Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PCextreme/cloudstack-php
Native PHP Cloudstack client
https://github.com/PCextreme/cloudstack-php
Last synced: 2 months ago
JSON representation
Native PHP Cloudstack client
- Host: GitHub
- URL: https://github.com/PCextreme/cloudstack-php
- Owner: PCextreme
- License: mit
- Created: 2016-08-17T21:36:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-05T13:27:13.000Z (about 6 years ago)
- Last Synced: 2024-11-18T09:53:37.951Z (3 months ago)
- Language: PHP
- Size: 243 KB
- Stars: 10
- Watchers: 8
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cloudstack - cloudstack-php (PHP)
README
[![github-readme_header](https://cloud.githubusercontent.com/assets/2406615/17754363/6e205280-64d4-11e6-946d-e7e7aedb2e30.png)](https://www.pcextreme.nl)
# PHP Cloudstack Client
[![Latest Version](https://img.shields.io/github/tag/PCextreme/cloudstack-php.svg?style=flat-square)](https://github.com/PCextreme/cloudstack-php/tags)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/PCextreme/cloudstack-php/blob/master/LICENSE)
[![Build Status](https://img.shields.io/travis/PCextreme/cloudstack-php/master.svg?style=flat-square)](https://travis-ci.org/PCextreme/cloudstack-php)
[![Scrutinizer](https://img.shields.io/scrutinizer/g/PCextreme/cloudstack-php/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/PCextreme/cloudstack-php/)
[![Coverage Status](https://img.shields.io/coveralls/PCextreme/cloudstack-php/master.svg?style=flat-square)](https://coveralls.io/r/PCextreme/cloudstack-php?branch=master)This package makes it simple to integrate the Cloudstack API in your PHP applications.
## Requirements
The following versions of PHP are supported:
* 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.
**Please note:** General support for PHP 5.x will be ending soon, [check the PHP documentation](http://php.net/supported-versions.php) for more information about PHP version support.
_If you still require support for PHP 5.x or HHVM you can use the `~0.2` [releases](/PCextreme/cloudstack-php/releases) of this package._
## Installation
Use `composer require` to add the client to your `composer.json` file, [please check the Composer documentation](https://getcomposer.org) for more information about Composer.
```
$ 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.
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.
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.
```php
'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.
```php
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.
```php
'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.
```
$ php bin/cloudstack api:list
```You can also get a list of available CLI commands.
```
$ 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](./CONTRIBUTING.md).
## Credits
- [Kevin Dierkx](https://github.com/kevindierkx)
- [Jesse Kramer](https://github.com/FrontEndCoffee)
- [All Contributors](https://github.com/pcextreme/cloudstack-php/contributors)## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.