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

ActiveLibrary

luket/php-router
================

PHP Routing Class

0151PHP

Since Nov 12Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

LukeT/PHP-Router
================

[](#luketphp-router)

A simple, drop-in PHP routing soloution.

- Easy to call routes
- Supports URL variables

### Installation

[](#installation)

You're required to have PHP 5.4 or higher due to the use of short arrays. The first way you can install is via including src/routes.php, although I don't recommend this. The second way is via composer:

```
composer require luket/php-router dev-master
composer update
```

### Usage

[](#usage)

Currently, use is fairly limited, but it gets the job done.

##### GET Requests

[](#get-requests)

```
Router::GET("/home", ["name" => "ACosmeticName", "function" => "showHome"]);
```

The first paramater is the URI you want to be called on, function is the function that you want to be called. Alternativly you can use:

```
Router::GET("/home", ["name" => "ACosmeticName", "controller" => "StaticPages@showAbout"]);
```

Which will call showAbout on the StaticPages class.

\#####POST Requests

Post requests accept the same paramaters, accept they will only respond to a POST reqeust.

```
Router::POST("/home", "controller" => "StaticController@handleHome");
```

In the future I may support PUT, DELETE, UPDATE etc.

##### URL Paramaters

[](#url-paramaters)

This also accepts URL paramates, so for instance  would be:

```
Router::GET("/[:alpha]/[:int]", ["function" => "doStuff()"]);
```

Currently accepted:

URIDescRegex\[:int\]Only allows an Interger as the paramater(\[a-zA-Z\]+)\[:alpha\]Allows any alpha-numberic string, including a-Z, A-Z and 0-9(\[0-9\]+)\[:string\]Allows only letters (a-z, A-Z)(\[a-zA-Z0-9-\_\]+)##### Make it work

[](#make-it-work)

Oh,Theres one thing you need to do to make it actually route.

```
Router::run();
```

and thats all there is too it!

### License

[](#license)

The MIT License (MIT)

Copyright (c) 2014 Luke Thompson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc3a374c715f068c4a087069f2d2ad8d6ecd66c50b61e1b9fe136a128573d33a?d=identicon)[LukeT](/maintainers/LukeT)

---

Top Contributors

[![LukeT](https://avatars.githubusercontent.com/u/2203091?v=4)](https://github.com/LukeT "LukeT (21 commits)")[![CihanAksoy](https://avatars.githubusercontent.com/u/1966483?v=4)](https://github.com/CihanAksoy "CihanAksoy (1 commits)")

### Embed Badge

![Health badge](/badges/luket-php-router/health.svg)

```
[![Health](https://phpackages.com/badges/luket-php-router/health.svg)](https://phpackages.com/packages/luket-php-router)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
