PHPackages                             tamce/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. [Framework](/categories/framework)
4. /
5. tamce/router

ActiveLibrary[Framework](/categories/framework)

tamce/router
============

A simple router helps you develop faster.

v1.0.1(8y ago)137MITPHP

Since Apr 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Tamce/Router)[ Packagist](https://packagist.org/packages/tamce/router)[ RSS](/packages/tamce-router/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Tamce/Router
============

[](#tamcerouter)

Summary
-------

[](#summary)

This is a simple router, some feature is just like Laravel's, but it's easier to use.
I hope this very very simple tool could help you a little bit, and i'm glad to get advice from you :)

Usage
-----

[](#usage)

```
composer require tamce/router

```

And you can just use it in your project!

### How to create a route

[](#how-to-create-a-route)

You can use simple `route` method to create a route or use `{http_verb}` method to create a route for specific HTTP requests. Every method that create a route recieve two arguments:

> uri, route

`uri` is a string that matches the uri, you can use regex exp in that string, and anything that matches the regex exp will be passed to the function you provided.
Also, you can use `{anything_you_want_here}` just like using `(^[/]+)` cause we replace `({[\w ]+})` that exp. We also replace `*` to `.*`, so you can simply use `*` to match all uri.

`route` can be a string or an array or a callable array/closure function.
**callable**: We just use `call_user_func_array` to call it.
**string**: The string will be parsed like this: `((file#)(namespace\)class@)method`
**array**: Just like the string, you can give us an array which look like this:

```
[
	'file'   => 'foo.php',                 // could be ignored
	'class'  => 'Namespace\ClassName',     // could be ignored
	'method' => 'methodName'
]

```

### using HTTP Verb or not

[](#using-http-verb-or-not)

You can create a simple route by using `route` method, or match the specific HTTP Verb using `{verb}` method.

### Route group

[](#route-group)

You can use `group` function to create a route group, and you can specific a namespace for each routes in the function so that Router can automatically look for the class you give in that namespace.

Examples
--------

[](#examples)

index.php

```
