PHPackages                             level3/level3 - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. level3/level3

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

level3/level3
=============

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

v0.0.4(12y ago)123476[1 issues](https://github.com/level3php/level3/issues)1MITPHPPHP &gt;=5.3.0

Since Jun 25Pushed 11y ago1 watchersCompare

[ Source](https://github.com/level3php/level3)[ Packagist](https://packagist.org/packages/level3/level3)[ Docs](http://github.com/yunait/level3)[ RSS](/packages/level3-level3/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (5)Versions (7)Used By (1)

Level3 RESTful API builder [![Build Status](https://camo.githubusercontent.com/e8ac4584c724ed21a66b7b0cf4d478421bcbbe63e93d635b5a23eaeb697b8c03/68747470733a2f2f7472617669732d63692e6f72672f6c6576656c337068702f6c6576656c332e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/level3php/level3)
==========================================================================================================================================================================================================================================================================================================

[](#level3-restful-api-builder-)

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

Read about *3-level model of restful maturity* at:

-
-

> Under heavy development

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

[](#requirements)

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

Installation
------------

[](#installation)

Add `level3/level3` to your composer requirements, you can see [the package information on Packagist.](https://packagist.org/packages/level3/level3):

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

Tests
-----

[](#tests)

Tests are in the `tests` folder. To run them, you need PHPUnit. Example:

```
$ phpunit --configuration phpunit.xml.dist

```

Documentation
-------------

[](#documentation)

### Overview

[](#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](https://github.com/level3php/level3-silex) for an example of how to do this using [Silex](http://silex.sensiolabs.org/)).

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.

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.

The `RepositoryHub` knows what `Repository` is responsible of fetching each kind of resource based on the `key`.

The `RepositoryMapper` knows about `Repositories` and `URLs`.

`Repositories` have to be extended in order to implement the logic in charge of handling resources from the storage system.

[![Classes overview](https://camo.githubusercontent.com/c0ca1662b732b761a9cae4e83849462062a6a71f679f2bdf9836eb0a704ca0b8/68747470733a2f2f7261772e6769746875622e636f6d2f6c6576656c337068702f6c6576656c332f6d61737465722f646f632f6f766572766965772e706e67)](https://camo.githubusercontent.com/c0ca1662b732b761a9cae4e83849462062a6a71f679f2bdf9836eb0a704ca0b8/68747470733a2f2f7261772e6769746875622e636f6d2f6c6576656c337068702f6c6576656c332f6d61737465722f646f632f6f766572766965772e706e67)

### Request and Response

[](#request-and-response)

Are the messages passed through a chain of `RequestProcessor`s. They encapsulate all the business logic.

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](http://symfony.com/) based framework can be returned directly since they extend its Response implementation.

### RequestProcessor

[](#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](https://raw.github.com/level3php/level3/master/doc/RequestProcessor.md):

#### AcessorWrapper

[](#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.

#### ExceptionHandler

[](#exceptionhandler)

Captures thrown exceptions and prints them in a convenient format, depending on the request headers. It also logs to a [PSR3 Logger](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).

#### RequestLogger

[](#requestlogger)

Logs all requests to a [PSR3 Logger](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).

#### AuthenticationProcessor

[](#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.

Read more about this [here](https://raw.github.com/level3php/level3/master/doc/AuthenticationProcessor.md).

#### AuthorizationProcessor

[](#authorizationprocessor)

Authorizes the request based on it's `getCredentials()` method. Several authorizators are provided:

- Role based authorizator
- ACL based authorizator

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

You can read more about `AurizationProcesor` [here](https://raw.github.com/level3php/level3/master/doc/AuthorizationProcessor.md).

### Repository

[](#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`.

License
-------

[](#license)

MIT, see [LICENSE](LICENSE)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Total

4

Last Release

4564d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1573114?v=4)[Máximo Cuadros](/maintainers/mcuadros)[@mcuadros](https://github.com/mcuadros)

---

Top Contributors

[![mcuadros](https://avatars.githubusercontent.com/u/1573114?v=4)](https://github.com/mcuadros "mcuadros (190 commits)")[![dripolles](https://avatars.githubusercontent.com/u/768061?v=4)](https://github.com/dripolles "dripolles (28 commits)")[![amartinj](https://avatars.githubusercontent.com/u/1821052?v=4)](https://github.com/amartinj "amartinj (6 commits)")[![filiptc](https://avatars.githubusercontent.com/u/2487390?v=4)](https://github.com/filiptc "filiptc (1 commits)")

---

Tags

resthalHATEOASrestfull

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/level3-level3/health.svg)

```
[![Health](https://phpackages.com/badges/level3-level3/health.svg)](https://phpackages.com/packages/level3-level3)
```

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)[bitrix24/b24phpsdk

An official PHP library for the Bitrix24 REST API

9230.2k4](/packages/bitrix24-b24phpsdk)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
