PHPackages                             plugowski/php\_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. plugowski/php\_router

ActiveLibrary[Framework](/categories/framework)

plugowski/php\_router
=====================

Simple routing engine, which allows anonymous functions to execute code on route.

1.0(10y ago)32412New BSDPHP

Since Feb 22Pushed 9y ago2 watchersCompare

[ Source](https://github.com/plugowski/php_router)[ Packagist](https://packagist.org/packages/plugowski/php_router)[ RSS](/packages/plugowski-php-router/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PhpRouter PhpRouter [![alt text](https://camo.githubusercontent.com/cd64116577441751384d17bffe8cbefd4aadd17a03cb18601981fc12a7f800a2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4253442d2d332d2d436c617573652d626c75652e737667 "Licence")](https://camo.githubusercontent.com/cd64116577441751384d17bffe8cbefd4aadd17a03cb18601981fc12a7f800a2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4253442d2d332d2d436c617573652d626c75652e737667) [![alt text](https://camo.githubusercontent.com/9b0c3b2436d1fe72975a6b32ea761ed69901fe5509031af5342d24cb25f89da1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d313925323025324625323031392d627269676874677265656e2e737667 "Tests")](https://camo.githubusercontent.com/9b0c3b2436d1fe72975a6b32ea761ed69901fe5509031af5342d24cb25f89da1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d313925323025324625323031392d627269676874677265656e2e737667) [![alt text](https://camo.githubusercontent.com/af813ae002de8e31bfd234a3d5eab4fe1963ed998df54d1f3c5e3e1fe334f7d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d677265656e2e737667 "Coverage")](https://camo.githubusercontent.com/af813ae002de8e31bfd234a3d5eab4fe1963ed998df54d1f3c5e3e1fe334f7d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d677265656e2e737667)
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#phprouter-phprouter---)

PHP router inspired on FatFree, CakePHP and own invention.

It allows to use anonymous functions as callback as well as OOP classes and methods. In addition, it detects if request is asynchronous or not (defined by \[ajax\] tag in rute definition).

Installation
------------

[](#installation)

Just clone that repository or use composer:

```
composer require plugowski/php_router
```

Next in your project create `.htaccess` file which point on your dispatcher file:

```

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php?url=$1 [QSA,L]

```

Usage
-----

[](#usage)

Basic usage looks like code below:

```
