PHPackages                             cherry-project/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. [HTTP &amp; Networking](/categories/http)
4. /
5. cherry-project/router

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cherry-project/router
=====================

Cherry-project Router

v1.1.0(7y ago)070[1 issues](https://github.com/cherry-framework/router/issues)1MITPHPPHP &gt;=5.6.0

Since Mar 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/cherry-framework/router)[ Packagist](https://packagist.org/packages/cherry-project/router)[ Docs](https://github.com/cherry-framework/router)[ RSS](/packages/cherry-project-router/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (1)

Cherry-Router
=============

[](#cherry-router)

The Cherry-project Router

[![GitHub license](https://camo.githubusercontent.com/499dcb4a675e802504dec91c8d94d790d8e36ebc25a8ada02f5384c534d422d3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616267656f30372f6368657272792d726f757465722e737667)](https://github.com/ABGEO07/cherry-router/blob/master/LICENSE)

[![GitHub release](https://camo.githubusercontent.com/5425bf4ebedd1819875751cdb8aadbeea527f146e87244bc0700ab646d9400a5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616267656f30372f6368657272792d726f757465722e737667)](https://github.com/ABGEO07/cherry-router/releases)

[![Packagist Version](https://camo.githubusercontent.com/30f254f1a4869eb53c841c295be7f14839ef423d321b0a5ca83183fcc4190dcb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368657272792d70726f6a6563742f726f757465722e737667 "Packagist Version")](https://packagist.org/packages/cherry-project/router "Packagist Version")

---

Including
---------

[](#including)

**Install from composer** `composer require cherry-project/router`

**Include Autoloader in your main file** (Ex.: index.php)

```
require_once __DIR__ . '/vendor/autoload.php';
```

Define application root directory

```
define('__ROOT__', __DIR__);
```

In your application you must have **config.json** file for storing app configuration settings and you must define his location:

```
define('CONFIG_FILE', __DIR__ . '/config/config.json');
```

**config.json** must contain path to **routes.json** and controllers directory

```
{
    "ROUTES_FILE": "config/routes.json",
    "CONTROLLERS_PATH": "controllers"
}
```

Get app config parameters and define it:

```
$config = file_get_contents(CONFIG_FILE)
    or die("Unable to open config file!");

$config = json_decode($config, 1);

foreach ($config as $k => $v)
    define($k, __DIR__ . '/' . $v);
```

**Notice**: This approach will be replaced in the new version :))

It's time to configure routes file

The routes file is a json file, where object key is route unique name.

Each route must have **path**, **method** and **action** keys. Homepage route example:

```
{
  "homepage": {
      "path": "/",
      "method": "GET",
      "action": "DefaultController::index"
  }
}
```

**Router file basic structure**

```
{
    "[RouteName]": {
        "path": "[URL]",
        "method": "[HTTP_Method]",
        "action": "[Controller]::[Method]"
    }
}
```

Definitions for router keys:

- **\[RouteName\]** - Route unique name;
- **path** - Route url. (Ex.: For address  \[URL\] is *homepage*);
- **method** - Route HTTP Method. Allowed all [HTTP methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods "HTTP methods");
- **action** - Route callback action. The firs part of action (before *::*) is your controller (stored in **CONTROLLERS\_PATH**). Controller is a simple [PHP Class](http://php.net/manual/en/language.oop5.php "PHP Class") where \[Controller\] is Class name (Class name and class filename must have same names (Ex.: **\[Controller\].php**)). The second part of action key (after ::) is controllers (class) public method;

Your route path can use **Placeholders**. Placeholder is a template of your route.

Route example with placeholder:

```
{
    "homepage": {
        "path": "/hello/{name}",
        "method": "GET",
        "action": "DefaultController::sayHello"
    }
}
```

There we have placeholder called **{name}** and we can get this value in controller:

```
public function sayHello($name)
{
    echo "Hello, {$name}";
}
```

**2019 © Cherry-project**

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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.

###  Release Activity

Cadence

Every ~29 days

Total

3

Last Release

2568d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/003cac08dd47c34ad3a5ed454c2968ed6afea9e26d57033867d4166fa08b3555?d=identicon)[ABGEO](/maintainers/ABGEO)

---

Top Contributors

[![ABGEO](https://avatars.githubusercontent.com/u/19558543?v=4)](https://github.com/ABGEO "ABGEO (23 commits)")

---

Tags

cherrycomposerrouterroutercherry

### Embed Badge

![Health badge](/badges/cherry-project-router/health.svg)

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

###  Alternatives

[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k789.4M1.8k](/packages/symfony-routing)[nikic/fast-route

Fast request router for PHP

5.3k92.4M668](/packages/nikic-fast-route)[altorouter/altorouter

A lightning fast router for PHP

1.3k3.4M68](/packages/altorouter-altorouter)[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6633.1M115](/packages/league-route)[aura/router

Powerful, flexible web routing for PSR-7 requests.

5231.5M67](/packages/aura-router)[coffeecode/router

A classic CoffeeCode Router is easy, fast and extremely uncomplicated. Create and manage your routes in minutes!

181111.1k5](/packages/coffeecode-router)

PHPackages © 2026

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