Download the PHP package ivan-novakov/php-perun-api without Composer
On this page you can find all versions of the php package ivan-novakov/php-perun-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ivan-novakov/php-perun-api
More information about ivan-novakov/php-perun-api
Files in ivan-novakov/php-perun-api
Package php-perun-api
Short Description A PHP client library to consume Perun REST API
License BSD-3-Clause
Homepage https://github.com/ivan-novakov/php-perun-api
Informations about the package php-perun-api
PHP Perun API
A client library written in PHP to consume Perun REST API.
Perun is a content management system that handles user identities, groups, resources and services. It is currently developed by CESNET, CERIT-SC together with students from Masaryk University in Brno.
Intro
This software is being developed as a part of the Shongo Project initiated by CESNET, a. l. e..
Requirements
- PHP >= 5.3.3
- cURL PHP extension
Installation
With Composer
To install the library through composer, add the following requirement to your composer.json
file:
"require": {
"ivan-novakov/php-perun-api": "~0.1"
}
And run composer install/update
.
Without composer
Just clone the repository and make sure, that your autoloader is properly set to search for the InoPerunApi
namespace in the project's src
directory.
Usage
Perun client configuration consists of several basic sections. The client
section is used for general configuration such as the url
of the Perun API instance.
The http_client
section configures the standard HTTP client object from Zend Framework 2. The authenticator
section configures the client authentication of the HTTP requests.
Once the we have the configuration, we can initialize the client:
After that, we can send requests to the remote API. For each Perun entity, there is a dedicated "manager" object, which can handle calls specific to the corresponding entity. For example, to get the user by its ID, we need to call the getUserById
method of the usersManager
. Any method arguments we need to pass should be included in the third argument of the sendRequest
call:
If there are problems while connecting to the remote API or if the response cannot be parsed properly, an exception will be thrown. Otherwise, we still need to check, if the request was successful:
If there is no error, we can access the response through the Payload
object:
Advanced usage (experimental)
The library may be used in a more intuitive way, which tries to "hide" the fact, that we are calling a remote API. The library tries to "mimic" the remote manager and entity objects:
We instantiate a "manager" object and pass a client object instance to its constructor. When we call a method on this object, it is caught by the magic __call()
method and a client request is constructed and dispatched. If the call was succesful, the User
entity is populated with data and returned.
License
Links
Author
All versions of php-perun-api with dependencies
zendframework/zend-stdlib Version ~2.3
zendframework/zend-http Version ~2.3
zendframework/zend-json Version ~2.3
zendframework/zend-console Version ~2.3