PHPackages                             beautybrands/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. beautybrands/router

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

beautybrands/router
===================

Lightweight URL Router

v2.0.13(5y ago)0427MITPHPPHP &gt;=7.1.3

Since May 20Pushed 5y agoCompare

[ Source](https://github.com/beautybrands/router)[ Packagist](https://packagist.org/packages/beautybrands/router)[ RSS](/packages/beautybrands-router/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (3)Versions (22)Used By (0)

Objectiveweb URL Router [![Build Status](https://camo.githubusercontent.com/3edef345fcc5caab83b80d4c1405fce4493fb2359ad7ca9fd4fd6c255afcc4be/68747470733a2f2f7472617669732d63692e6f72672f6f626a6563746976657765622f726f757465722e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/3edef345fcc5caab83b80d4c1405fce4493fb2359ad7ca9fd4fd6c255afcc4be/68747470733a2f2f7472617669732d63692e6f72672f6f626a6563746976657765622f726f757465722e7376673f6272616e63683d6d6173746572)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#objectiveweb-url-router-)

Lightweight url router with dependency injection support.

Instalation
-----------

[](#instalation)

Add the dependency to `composer.json`, then `composer install`

```
{
    "require": {
        "beautybrands/router": "~2.0"
    }
}

```

Basic Usage
-----------

[](#basic-usage)

In Objectiveweb applications, an endpoint refers to a php file which responds to url routes.

Under the hood, the `route($regex, $callable)` function tests `$regex` against the current request method and uri (e.g. "GET endpoint.php/something/(\[0-9\]+)/?"), passing the captured parameters to `$callable` when matched.

### Example endpoint

[](#example-endpoint)

```
