krak / api
A library used for developing RESTful Apis
Requires
- doctrine/common: ^2.0
- krak/marshal: ^0.1
- nicmart/string-template: ^0.1
- nikic/iter: ^1.0
- symfony/http-foundation: ^2.0
Requires (Dev)
- pimple/pimple: ~3.0
- symfony/event-dispatcher: ~2.0
- symfony/http-kernel: ~2.0
README
A framework designed for building apis using the Symfony HttpKernel
Installation
Installation via composer:
{
"require": {
"krak/api": "^0.6"
}
}
Event Listener
The Event Listener holds an option ViewListener that will take the result of your controllers and use an http converter to convert them into a proper response.
HttpConverter
Converts and formats an Api Response into a HTTP Response in the proper format.
Response
A response is the vehicle for your api data. The Response holds the status type and builds an extra headers or status information around the data.
ResponseMarshaler
Response Marshalers take a response and create the array data to be converted to an Http response.
Usage
ResponseMarshalers are attached to HttpConverters.
use Krak\Api\HttpConverter\JsonHttpConverter;
use Krak\Api\ResponseMarshaler\StatusResponseMarshaler;
$converter = new JsonHttpConverter();
$converter->setResponseMarshaler(new StatusResponseMarshaler());
StatusResponseMarshaler
The status response marshaler will add a status field to the response data
Todo
- Create marshalers and fix the Response object model