Download the PHP package tbbc/rest-util without Composer
On this page you can find all versions of the php package tbbc/rest-util. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rest-util
The Big Brains Company - Rest Util
Rest util library for PHP.
This library implement some useful util classes for resolving recurrent issues in Rest(ful) APIs (i.e: Error handling).
Quick Start
Table of contents
- Installation
- Getting started
- Usage
- Run the test
- Contributing
- Requirements
- Authors
- License
Description
Rest utilitary library for PHP
Installation
Using Composer, just $ composer require tbbc/rest-util
package or:
Usage
Converting Exception into Error object:
1. First you have to define an ExceptionMapping
, for the sake of the example,
we use PHP
, but a YamlLoader
is also available:
2. The ExceptionMapping
must be added to ExceptionMap
:
3. We plug the ErrorResolver
with an ErrorFactory, a DefaultErrorFactory
is bundled within the lib:
4. Resolve error!
5. The $error
variable is now assigned an ErrorInterface
object which implements a toArray()
method
to allow easy serialization method of your choice:
For more concrete real life usage, take a look at our bundle for integrating the lib into a Symfony application: TbbcRestUtilBundle.
Run the test
First make sure you have installed all the dependencies, run:
$ composer install --dev
then, run the test from within the root directory:
$ vendor/bin/phpunit
Contributing
- Take a look at the list of issues.
- Fork
- Write a test (for either new feature or bug)
- Make a PR
Requirements
- PHP 5.3+
Authors
- Boris Guéry - [email protected] - http://borisguery.com
- Benjamin Dulau - [email protected]
License
The Big Brains Company - Rest Util
is licensed under the MIT License - see the LICENSE file for details