PHPackages                             codeinc/router - 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. [API Development](/categories/api)
4. /
5. codeinc/router

AbandonedArchivedLibrary[API Development](/categories/api)

codeinc/router
==============

Code Inc. PSR7 &amp; PSR15 router library

4.0.0(7y ago)2612MITPHPPHP &gt;=7.1

Since Dec 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/CodeIncHQ/Router)[ Packagist](https://packagist.org/packages/codeinc/router)[ Docs](https://github.com/CodeIncHQ/Router)[ RSS](/packages/codeinc-router/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (9)Versions (76)Used By (2)

PSR-7 &amp; PSR-15 router library
=================================

[](#psr-7--psr-15-router-library)

This library provides a [PSR-7](https://www.php-fig.org/psr/psr-7/) and [PSR-15](https://www.php-fig.org/psr/psr-15/) compatible router. The router is a component in charge or selecting the appropriate controller (implementing [`ControllerInterface`](src/ControllerInterface.php)). It behaves as a [PSR-15 middleware](https://www.php-fig.org/psr/psr-15/#12-middleware) ([`MiddlewareInterface`](https://github.com/http-interop/http-middleware/blob/master/src/MiddlewareInterface.php)).

Resolvers
---------

[](#resolvers)

In order to select a controller, the router relies on a resolver (implementing [`ResolverInterface`](src/Resolvers/ResolverInterface.php)). Resolvers are in charge of matching a URI path (called a route) to a controller and vice versa, mapping a controller to a route. Two resolvers are provided, [`StaticResolver`](src/Resolvers/StaticResolver.php) which uses a list of preset patterns (shell patterns resolved by [`fnmatch()`](http://php.net/manual/function.fnmatch.php)) matching handler's classes and [`DynamicResolver`](src/Resolvers/DynamicResolver.php) which dynamically calculates the routes of namespaces base on a PHP namespace and a base URI. You can pair multiple resolvers using [`ResolverAggregator`](src/Resolvers/ResolverAggregator.php). External packages provides resolvers based on [Doctrine's annotations](https://github.com/CodeIncHQ/RouterAnnotationResolver) or on [interfaces](https://github.com/CodeIncHQ/RouterRoutableResolver).

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
