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

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

objectiveweb/router
===================

Lightweight URL Router

v2.0.10(8y ago)11.1k2MITPHPPHP &gt;=5.4.0

Since May 20Pushed 4mo ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (21)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": {
        "objectiveweb/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)

```
