PHPackages                             cheechstack/routing - 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. cheechstack/routing

ActiveLibrary[Framework](/categories/framework)

cheechstack/routing
===================

Router and route classes for the CheechStack framework.

v1.1.0(3mo ago)117MITPHPPHP &gt;=8.4.0

Since Sep 24Pushed 3mo agoCompare

[ Source](https://github.com/cheechstack/routing)[ Packagist](https://packagist.org/packages/cheechstack/routing)[ RSS](/packages/cheechstack-routing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

CheechStack : Routing
=====================

[](#cheechstack--routing)

Simple Router and Route classes to support the CheechStack PHP framework. This library depends on `symfony/http-foundation:^7.3`. Full documentation can be found on [GitHub.](https://github.com/cheechstack/routing)

> **Note:** This library is under active development and is subject to change at any point.

Installation:
-------------

[](#installation)

CheechStack/Routing is available as a standalone package from Composer.

`composer require cheechstack/routing`

Usage:
------

[](#usage)

1. Create a `Router` object.

    ```
    use Cheechstack\Routing\Router;

    $router = new Router();
    ```
2. Create your `Routes`...

    ```
    use Cheechstack\Routing\Route;

    $routes = [
        new Route("/foo", "GET", fn() => 'bar'),
        new Route("/marco", "GET", fn() => 'polo'),
    ];
    ```

    ...and add them to the `Router`.

    ```
    $router->add($routes);
    ```

    Routes may also be added one at a time.

    ```
    $router->add(new Route('/foo', "GET", fn() => 'bar'));
    $router->add(new Route('/marco', "GET", fn() => 'polo'));
    ```
3. Handle the request and send back the Router's response.

    ```
    $response = $router->handle($request);

    $response->send();
    ```

Routes:
-------

[](#routes)

CheechStack supports two types of routes:

### 1. Static Routes

[](#1-static-routes)

Static routes match a fixed URL path.

- Example: ```
    $route = new Route("/foo/bar", "GET", fn() => "baz");
    ```

    - This route will **only** match to `/foo/bar`.
    - Great for endpoints that do not change i.e `/login`, `/about`, `/status`, etc...

### 2. Dynamic Routes

[](#2-dynamic-routes)

Dynamic routes include parameters in the path, defined with a `:` prefix. [Accessing the route parameters is covered here.](#accessing-path-parameters-within-callbacks)

```
$route = new Route("/foo/:bar", "GET", fn() => "baz");
```

- This route will match to `/foo/bar`, `/foo/baz`, `/foo/ruh_roh_raggie`, etc...
- This route will **NOT** match `/foo/baz/tripped_up`.

Route Callbacks:
----------------

[](#route-callbacks)

The simplest form of callback for a `Route` is an anonymous function.

```
// Returns the string "bar" when a request is sent to "/foo"

$route = new Route('/foo', "GET", fn() => 'bar')
```

Callbacks can also be defined via static methods on Controllers. For example:

```
use Symfony\Component\HttpFoundation\Response;

class Controller
{
    // Return the "foo" page
    public static function foo() : Response
    {
        // Return "Bar!" as the content for the response.

        return new Response("Bar!", 200);
    }
}

$route = new Route('/foo', "GET", [Controller::class, 'foo']);
```

### Accessing Request Values Within Callbacks:

[](#accessing-request-values-within-callbacks)

To access the `Request` object from within the Route's callback, simply declare a `Request` object in the callback's definition. Both examples return the requested url.

As an anonymous function:

```
$route = new Route('/foo', "GET", fn(Request $request) => $request->getPathInfo());
```

As a static method:

```
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class Controller
{
    public static function foo(Request $request) : Response
    {
        return new Response($request->getPathInfo(), 200);
    }
}

$route = new Route("/foo", "GET", [Controller::class, 'foo']);
```

### Accessing Path Parameters Within Callbacks:

[](#accessing-path-parameters-within-callbacks)

To access any path parameters used within your route, you may also pass a `$params` variable of `mixed` type **in addition** to the `Request` object. Parameters are then available in an array-like structure and accessible via their placeholder value.

As an anonymous function:

```
$route = new Route('/foo/:bar', "GET", fn(Request $request, mixed $params) => $params['bar']);

// Request to /foo/baz => returns "baz"
```

As a static method:

```
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class Controller
{
    public static function foo(Request $request, mixed $params) : Response
    {
        return new Response($params['bar'], 200);
    }
}

$route = new Route("/foo/:bar", "GET", [Controller::class, 'foo']);

// Request to /foo/baz => returns "baz"
```

### Accessing Query Parameters Within Callbacks:

[](#accessing-query-parameters-within-callbacks)

Access query parameters the same way you would on the standard Symfony `Request` object. Simply declare the `Request` object in the callback definition and access the parameters via the `$request->get()` method or similar.

```
$route = new Route('/foo', "GET", fn(Request $request) => $request->get('bar'));

// Request to /foo?bar=baz => returns "baz"
```

---

Changelog
=========

[](#changelog)

1.0.0
-----

[](#100)

- Better (more) documentation.
- Added support for accessing path parameters directly from callbacks.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance82

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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 ~146 days

Total

2

Last Release

90d ago

### Community

Maintainers

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

---

Top Contributors

[![krbeasley](https://avatars.githubusercontent.com/u/113050198?v=4)](https://github.com/krbeasley "krbeasley (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cheechstack-routing/health.svg)

```
[![Health](https://phpackages.com/badges/cheechstack-routing/health.svg)](https://phpackages.com/packages/cheechstack-routing)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k235.4M9.7k](/packages/symfony-framework-bundle)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.6k9.4M48](/packages/laravel-reverb)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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