PHPackages                             triquanta/libizi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. triquanta/libizi

ActiveLibrary

triquanta/libizi
================

2.0.11(10y ago)11.2k4MITPHPPHP ~5.4

Since May 6Pushed 10y ago6 watchersCompare

[ Source](https://github.com/Triquanta/libizi)[ Packagist](https://packagist.org/packages/triquanta/libizi)[ RSS](/packages/triquanta-libizi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (14)Used By (0)

About
=====

[](#about)

[![Build Status](https://camo.githubusercontent.com/1c6d419b615f798def52cec4737ef60c4e12b86c9a6a01e8dba358e434e468f2/68747470733a2f2f7472617669732d63692e6f72672f5472697175616e74612f6c6962697a692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Triquanta/libizi)

This is a PHP library for communicating with the [izi.TRAVEL API](http://api-docs.izi.travel/).

Requirements
------------

[](#requirements)

All requirements are resolved through [Composer](http://getcomposer.org). After installing composer, go to the project root and run `composer install` to install all dependencies.

Usage &amp; features
--------------------

[](#usage--features)

### Client

[](#client)

The library provides a client to communicate with the API. It handles all requests, errors, and converts all API output to classes PHP objects. Three preparatory steps must be taken before API calls can be made:

1. Create a `\GuzzleHttp\Client` instance.
2. Create a `\Triquanta\IziTravel\Client\*RequestHandler` instance and inject the Guzzle client from step 1 and an API key.
3. Create a [`Triquanta\IziTravel\Client\Client`](./src/Client/Client.php)instance and inject the request handler from step 2.

Now you can call any of the methods on the client from step 3 and get the API's output as (arrays of) classed PHP objects.

### Data types

[](#data-types)

Because working with raw, untyped data in PHP is bad developer experience (DX), every data type in the API has corresponding interfaces and classes in this library. All classes come with factory methods ([`\Triquanta\IziTravel\DataType\FactoryInterface`](./src/DataType/FactoryInterface.php)) to instantiate an object based on the API's raw JSON response.

### Events

[](#events)

[Symfony EventDispatcher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html)is used for dispatching system events. Event names and classes are documented in [`\Triquanta\IziTravel\Event\IziTravelEvents`](./src/Event/IziTravelEvents.php).

Development
-----------

[](#development)

### Versioning

[](#versioning)

All development takes places on the `master` branch. Versions are released based on [Semantic Versioning](http://semver.org).

### Supporting a new API endpoint

[](#supporting-a-new-api-endpoint)

Each API endpoint is represented by a request class in [`\Triquanta\IziTravel\Request`](./src/Request) and it must implement [`\Triquanta\IziTravel\Request\RequestInterface`](./src/Request/RequestInterface.php). It can optionally implement any of the other [interfaces](http://php.net/manual/en/language.oop5.interfaces.php) in the same namespace and use any of the [traits](http://php.net/manual/en/language.oop5.traits.php) to quickly build a configurable request. Any object data returned by an endpoint must be converted to classed objects before being returned by `\Triquanta\IziTravel\Request\RequestInterface::execute()` implementations. The existing data types in [`Triquanta\IziTravel\DataType`](./src/DataType) can be re-used. [`\Triquanta\IziTravel\ClientInterface`](./src/Client/ClientInterface.php) is a convenience layer for easily requesting data from different endpoints in the same code. When adding a new request class, a method for it must be added to this interface as well.

#### Example

[](#example)

A new endpoint `foo` was added for retrieving *Foo* content by UUID. Additionally the content can be returned in a specific language and format (full/compact). The first step is to create a class that implements the correct interface (which is inherited from [`RequestBase`](./src/Request/RequestBase.php)):

```
