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

ActiveLibrary[Framework](/categories/framework)

terrazza/routing
================

Terrazza Component Routing

0171PHP

Since May 11Pushed 4y agoCompare

[ Source](https://github.com/webfux/routing)[ Packagist](https://packagist.org/packages/terrazza/routing)[ RSS](/packages/terrazza-routing/feed)WikiDiscussions main Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (1)

the routing component
=====================

[](#the-routing-component)

The component match routes.
*The component does not include any class loading or injection.*
*The only goal is: **find/match routes***

1. Object/Classes
    1. [Route](#object-route)
    2. [RouteSearch](#object-route-search)
    3. [RouteMatcher](#object-route-matcher)
2. [Install](#install)
3. [Requirements](#require)
4. [Examples](#examples)

Object/Classes
--------------

[](#objectclasses)

### Route

[](#route)

The class covers the "route" to a given Controller ($className). Properties:

- uri (string, required)
- className (string, required)
- methods (array, optional)
- arguments (array, optional)

#### method: hasMethod(string $method) : bool

[](#method-hasmethodstring-method--bool)

If the [Route](#object-route) includes methods (which is optional) hasMethod validate the give one.
*notice:
$method "HEAD" will be replaced with "GET"*

### RouteSearch

[](#routesearch)

The class covers the base uri, method and arguments. All [Routes](#object-route) are matched against this object.
Properties:

- uri (string, required)
- method (string, required, default=GET)
- arguments (array, optional)

### RouteMatcher

[](#routematcher)

#### method: getRoute(RouteSearch $routeSearch, array $routes) :?Route

[](#method-getrouteroutesearch-routesearch-array-routes-route)

To get a route is done in two steps.

1. match Route-&gt;uri against routeSearch-&gt;uri + method + arguments
2. get all public methods within the annotation @Route/uri and match against routeSearch + method + arguments
    **The annotation URI is without the Controller Route Uri and is required**

How to install
--------------

[](#how-to-install)

### Install via composer

[](#install-via-composer)

```
composer require terrazza/routing

```

Requirements
------------

[](#requirements)

### php version

[](#php-version)

- &gt;= 7.4

### composer packages

[](#composer-packages)

- psr/log

Examples
--------

[](#examples)

**notice: The example requires a Psr\\Log\\LoggerInterface implementation**

```

use Terrazza\Component\Routing\Route;
use Terrazza\Component\Routing\RouteMatcher;
use Terrazza\Component\Routing\RouteSearch;

class ControllerPayment {
    /**
     * @Route/method GET
     * @Route/uri /view1
     * @return string
     */
    function methodView1() : string {
        return "methodView1";
    }

    /**
     * @Route/method GET
     * @Route/uri /{id}
     * @return string
     */
    function methodById() : string {
        return "methodById";
    }

    /**
     * @Route/method GET
     * @Route/uri /view3
     * @return string
     */
    function methodView3() : string {
        return "methodView3";
    }
}

class ControllerPaymentView {
    /**
     * @Route/method GET
     * @Route/uri /{id}
     * @return string
     */
    function paymentView() : string {
        return "paymentView";
    }
}

$routes     = [
    new Route("payment", ControllerPayment::class),
    new Route("payment/view", ControllerPaymentView::class),
];

//
// Psr\Log\LoggerInterface implementation
//
$logger = "IMPORTANT ! has to initialized";

echo (new RouteMatcher($logger))
    ->getRoute(new RouteSearch("payment/view1"), $routes)->getClassMethodName();
// found in ControllerPayment, method methodView1

echo (new RouteMatcher($logger))
    ->getRoute(new RouteSearch("payment/view/1"), $routes)->getClassMethodName();
// found ControllerPayment, method methodView2 but will be skipped cause $id includes /
// found in ControllerPaymentView, method paymentView

echo (new RouteMatcher($logger))
    ->getRoute(new RouteSearch("payment/view3"), $routes)->getClassMethodName(),
// found in ControllerPayment, method methodView3

echo (new RouteMatcher($logger))
    ->getRoute(new RouteSearch("payment/view4"), $routes)->getClassMethodName(),
// found in ControllerPayment, method methodById

```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 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/6aac82b92100438501756aab68d05fe45243631c8901ac45f75b07cef378ef04?d=identicon)[webfux](/maintainers/webfux)

---

Top Contributors

[![ecashview](https://avatars.githubusercontent.com/u/30357454?v=4)](https://github.com/ecashview "ecashview (3 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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