PHPackages                             amitkhare/easy-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. [API Development](/categories/api)
4. /
5. amitkhare/easy-router

ActiveLibrary[API Development](/categories/api)

amitkhare/easy-router
=====================

EasyRouter is an easy to use minimal PHP routing system.

144PHP

Since Dec 9Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

amitkhare/easy-router
=====================

[](#amitkhareeasy-router)

\##EasyRouter is an easy to use minimal PHP routing system

INSTALL
-------

[](#install)

### VIA COMPOSER

[](#via-composer)

```
composer require amitkhare/easy-router dev-master
```

### VIA GIT

[](#via-git)

```
git clone https://github.com/amitkhare/easy-router.git
```

EXAMPLE USAGE
-------------

[](#example-usage)

### .HTACCESS FILE

[](#htaccess-file)

```
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
```

### MINIMAL EXAMPLE

[](#minimal-example)

```
add('GET','/product/{id:num}', function($id){
	echo  $id;
});

// OR Callback of a class->method()
// URL::GET www.example.com/
$router->add("GET",'/', [Page::class,"home"])->setName('home');

// Dispatch Routes.
$router->dispatch();
```

### DETAILED EXAMPLE

[](#detailed-example)

```
123],$baseURI);

// URL::GET www.example.com/
$router->add("GET",'/', [Page::class,"home"])->setName('home');

// URL::GET www.example.com/article/tshirts/323
// anonymous callback function
$router->add("GET",'/article/{category:w}/{id:num}/', function($category, $id){
    echo "Category: ".$category."";
    echo "ID: ".$id;
});

// URL::GET www.example.com/product/222
$router->add("GET",'/product/{id:d}', [Page::class,"product"]);

// URL::POST www.example.com/product
$router->add("POST",'/product', [Page::class,"product_process"]);

// URL::GET www.example.com/about/something/
$router->add("GET",'/about/{var1:w}', [Page::class,"about"],['myname'=>'amitkhare']);

// Dispatch Routes.
$router->dispatch();
```

### PAGE CLASS

[](#page-class)

```
namespace App\Controllers;

class Page {
	public function __construct($vars=[]) {
		foreach ($vars as $key => $value) {
			$this->$key= $value;
		}
	}
	public function get($vars)
	{
		echo $this->db."";
		echo $this->var1."";
		echo $this->var1."";
		print_r($vars);
	}
	public function about($vars)
	{
		echo $vars->var1."";
		echo $vars->myname."";
	}
	public function product($vars)
	{
		echo " ID: ".$vars->id;
	}
	public function home()
	{
		echo "this is home.";
	}
	public function product_process()
	{
		echo "this will show only if accessed via POST method.";
	}
}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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/996432dec074fe5ed8ed00ac19c727c4ecc6f59f8b0f57c42f0d7c446e346d72?d=identicon)[amitkhare](/maintainers/amitkhare)

---

Top Contributors

[![amitkhare](https://avatars.githubusercontent.com/u/1593383?v=4)](https://github.com/amitkhare "amitkhare (116 commits)")

---

Tags

libraryphprouter

### Embed Badge

![Health badge](/badges/amitkhare-easy-router/health.svg)

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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