PHPackages                             ellipse/router-aura - 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. ellipse/router-aura

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

ellipse/router-aura
===================

Aura router Psr-15 middleware and request handler

1.0.1(8y ago)040MITPHPPHP &gt;=7.0

Since Jan 31Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ellipsephp/router-aura)[ Packagist](https://packagist.org/packages/ellipse/router-aura)[ Docs](https://github.com/ellipsephp/router-aura)[ RSS](/packages/ellipse-router-aura/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (4)Used By (0)

Aura router
===========

[](#aura-router)

Aura router [Psr-15](https://www.php-fig.org/psr/psr-15/) middleware and request handler.

**Require** php &gt;= 7.0

**Installation** `composer require ellipse/router-aura`

**Run tests** `./vendor/bin/kahlan`

- [Usage as request handler](https://github.com/ellipsephp/router-aura#usage-as-request-handler)
- [Usage as middleware](https://github.com/ellipsephp/router-aura#usage-as-middleware)

Usage as request handler
------------------------

[](#usage-as-request-handler)

This package provides an `Ellipse\Router\AuraRouterRequestHandler` Psr-15 request handler taking an instance of `Aura\Router\RouterContainer` as parameter.

This aura router is expected to have a populated map or to have a map builder defined, usually using its `->setMapBuilder()` method. The route handlers it matches are expected to be implementations of `Psr\Http\Server\RequestHandlerInterface`.

When the `AuraRouterRequestHandler` handles a request the aura router is used to match a Psr-15 request handler. When the matched route pattern contains placeholders, a new request is created with those placeholders =&gt; matched value pairs as request attributes. Finally the matched request handler is proxied with this new request to actually return a response.

Setting the aura router map builder using its `->setMapBuilder()` method allows the time consuming task of mapping routes to be performed only when the request is handled with the `AuraRouterRequestHandler`. If for some reason an application handles the incoming request with another request handler, no time is lost mapping routes for this one.

Regarding exceptions:

- An `Ellipse\Router\Exceptions\MatchedHandlerTypeException` is thrown when the route handler matched by the aura router is not an implementation of `Psr\Http\Server\RequestHandlerInterface`.
- An `Ellipse\Router\Exceptions\NotFoundException` is thrown when no route match the url.
- An `Ellipse\Router\Exceptions\MethodNotAllowedException` is thrown when a route matches the url but the request http method is not allowed by the matched route.
- An `Ellipse\Router\Exceptions\AuraMatcherException` is thrown when any other aura router rule failed.

```
