2017 © Pedro Peláez
 

library level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

image

level3/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  • Thursday, May 29, 2014
  • by mcuadros
  • Repository
  • 3 Watchers
  • 13 Stars
  • 322 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Level3 RESTful API builder Build Status

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia), (*1)

Read about 3-level model of restful maturity at: * http://www.infoq.com/news/2010/03/RESTLevels * http://www.crummy.com/writing/speaking/2008-QCon/act3.html, (*2)

Under heavy development, (*3)

Requirements

  • PHP 5.4.x
  • shrikeh/teapot
  • symfony/http-foundation
  • psr/log

Installation

Add level3/level3 to your composer requirements, you can see the package information on Packagist.:, (*4)

{
    "require": {
        "level3/level3": "dev-master"
    }
}

Tests

Tests are in the tests folder. To run them, you need PHPUnit. Example:, (*5)

$ phpunit --configuration phpunit.xml.dist

Documentation

Overview

Level3 only provides the handling of already parsed requests. These requests extend Symfony\Component\HttpFoundation\Request and add some extra functionality. You have to to create these requests from whatever delivery mechanism/framework you are using (see level3-silex for an example of how to do this using Silex)., (*6)

These requests travel along a series of RequestProcessor instances that can authenticate, authorize and modify them. The last RequestProcessor is the AccessorWrapper. It knows how to translate a request into a call for the Accessor, and interpret the return of that call to turn it into a Response (which extends Symfony\Component\HttpFoundation\Response) object., (*7)

The Accessor is in charge of asking the RepositoryHub for the Repository in charge of handling the fetching of the requested resource and querying it., (*8)

The RepositoryHub knows what Repository is responsible of fetching each kind of resource based on the key., (*9)

The RepositoryMapper knows about Repositories and URLs., (*10)

Repositories have to be extended in order to implement the logic in charge of handling resources from the storage system., (*11)

Classes overview, (*12)

Request and Response

Are the messages passed through a chain of RequestProcessors. They encapsulate all the business logic., (*13)

On the one hand the Controller handling the HTTP request has to create a Request object, but on the other hand, Level3 Response objects, in the case of using a Symfony based framework can be returned directly since they extend its Response implementation., (*14)

RequestProcessor

All subclasses are intended to handle the request, pass it to the next processor, get their response, handle it, and reuturn it. They can be chained in order to implement any kind of functionality. Some default are already provided as an example, since they can also be useful (you can read more about RequestProcessor here:, (*15)

AcessorWrapper

Is the only mandatory RequestProcessor. It translates the request into a RepositoryFriendly format and generates a response from its response. If chained to others, this has to be the last one in the chain., (*16)

ExceptionHandler

Captures thrown exceptions and prints them in a convenient format, depending on the request headers. It also logs to a PSR3 Logger., (*17)

RequestLogger

Logs all requests to a PSR3 Logger., (*18)

AuthenticationProcessor

This class authenticates the request and sets proper credentials in order to, later, authorize or not the request. The way the authentication is handled is done using implementations of Level3\Security\Authentication\Method. By default, HMAC is used., (*19)

Read more about this here., (*20)

AuthorizationProcessor

Authorizes the request based on it's getCredentials() method. Several authorizators are provided: * Role based authorizator * ACL based authorizator, (*21)

By default, all request have anonymous credentials, so if no AuthenticationProcessor is chained before, this is what you can expect., (*22)

You can read more about AurizationProcesor here., (*23)

Repository

Is the one in charge of retrieving the data from the underlying storage and returning a Level3\Hal\Resource with some help from Level3\Hal\ResourceBuilder., (*24)

License

MIT, see LICENSE, (*25)

The Versions

29/05 2014

dev-master

9999999-dev http://github.com/level3php/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest hal restful siren hateoas

19/11 2013

dev-request

dev-request http://github.com/level3php/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest hal restful siren hateoas

15/11 2013

dev-siren

dev-siren http://github.com/yunait/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

rest hal hateoas restfull

14/11 2013

v0.0.4

0.0.4.0 http://github.com/yunait/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

rest hal hateoas restfull

27/06 2013

v0.0.3

0.0.3.0 http://github.com/yunait/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

rest hal hateoas restfull

26/06 2013

v0.0.2

0.0.2.0 http://github.com/yunait/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

rest hal hateoas restfull

25/06 2013

v0.0.1

0.0.1.0 http://github.com/yunait/level3

A RESTful API builder based on 3-level model (URI, HTTP and Hypermedia)

  Sources   Download

MIT

The Requires

 

The Development Requires

rest hal hateoas restfull