PHPackages                             sirix/mezzio-routing-contracts - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. sirix/mezzio-routing-contracts

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

sirix/mezzio-routing-contracts
==============================

Contracts for sirix/mezzio-routing-attributes route attribute modifiers

1.0.0(2mo ago)0718↑866.7%4MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since May 9Pushed 2mo agoCompare

[ Source](https://github.com/sirix777/mezzio-routing-contracts)[ Packagist](https://packagist.org/packages/sirix/mezzio-routing-contracts)[ Fund](https://buymeacoffee.com/sirix)[ GitHub Sponsors](https://github.com/sirix777)[ RSS](/packages/sirix-mezzio-routing-contracts/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (4)

Mezzio Routing Contracts
========================

[](#mezzio-routing-contracts)

[![Latest Stable Version](https://camo.githubusercontent.com/b86220b6fe15a594b5a2fa9f310dee7a62fd61693f4d3f7b627e017b5dc98723/687474703a2f2f706f7365722e707567782e6f72672f73697269782f6d657a7a696f2d726f7574696e672d636f6e7472616374732f76)](https://packagist.org/packages/sirix/mezzio-routing-contracts) [![Total Downloads](https://camo.githubusercontent.com/e1a14af5b3a75c751d6158918e482ffdc1c5480bcea79e0c9e64d5e1fb5a3b14/687474703a2f2f706f7365722e707567782e6f72672f73697269782f6d657a7a696f2d726f7574696e672d636f6e7472616374732f646f776e6c6f616473)](https://packagist.org/packages/sirix/mezzio-routing-contracts) [![Latest Unstable Version](https://camo.githubusercontent.com/596197e271ca0123afa99305f129d270a1f9d78448269b92803156e4d252be67/687474703a2f2f706f7365722e707567782e6f72672f73697269782f6d657a7a696f2d726f7574696e672d636f6e7472616374732f762f756e737461626c65)](https://packagist.org/packages/sirix/mezzio-routing-contracts) [![License](https://camo.githubusercontent.com/cc427abab5248780f14ad03cf14f42d90f135af3cc0bb26a7d71ab550f25a03e/687474703a2f2f706f7365722e707567782e6f72672f73697269782f6d657a7a696f2d726f7574696e672d636f6e7472616374732f6c6963656e7365)](https://packagist.org/packages/sirix/mezzio-routing-contracts) [![PHP Version Require](https://camo.githubusercontent.com/d773efe2e2674bebc67212edea52420c9dc79183337d6dfe6346f8ce265d7f7c/687474703a2f2f706f7365722e707567782e6f72672f73697269782f6d657a7a696f2d726f7574696e672d636f6e7472616374732f726571756972652f706870)](https://packagist.org/packages/sirix/mezzio-routing-contracts)

Contracts for [sirix/mezzio-routing-attributes](https://github.com/sirix777/mezzio-routing-attributes) route attribute modifiers.

This package contains the stable public contract used by routing attributes that need to contribute middleware or default route options to a route definition.

Installation
------------

[](#installation)

```
composer require sirix/mezzio-routing-contracts
```

Usage
-----

[](#usage)

Implement `RouteAttributeModifierInterface` on any route-related attribute to inject middleware and/or provide default route options.

```
use Attribute;
use Sirix\Mezzio\Routing\Contracts\RouteAttributeModifierInterface;

#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final readonly class RequireTenant implements RouteAttributeModifierInterface
{
    public function __construct(private string $tenantHeader = 'x-tenant-id') {}

    public function getMiddleware(): array
    {
        return [RequireTenantMiddleware::class];
    }

    public function getDefaults(): array
    {
        return ['tenant_header' => $this->tenantHeader];
    }
}
```

Usage with routing attributes:

```
use Sirix\Mezzio\Routing\Attributes\Attribute\Get;

final class OrdersHandler
{
    #[Get('/orders', name: 'orders.list')]
    #[RequireTenant('x-org-id')]
    public function list(): ResponseInterface
    {
        // ...
    }
}
```

The routing-attributes package discovers all implementations of `RouteAttributeModifierInterface` at boot time and merges their middleware and defaults into the route definition.

Contract
--------

[](#contract)

```
interface RouteAttributeModifierInterface
{
    /** @return list */
    public function getMiddleware(): array;

    /** @return array */
    public function getDefaults(): array;
}
```

### `getMiddleware()`

[](#getmiddleware)

Returns middleware identifiers that should be appended to the route pipeline. Each item must be a middleware class name implementing `Psr\Http\Server\MiddlewareInterface` or another non-empty middleware identifier supported by the consuming router integration.

### `getDefaults()`

[](#getdefaults)

Returns default route options keyed by option name. Consumers merge these values into the route defaults/options for the route that carries the attribute.

Versioning
----------

[](#versioning)

The `1.x` series follows [Semantic Versioning](https://semver.org/). Breaking changes to public contracts are reserved for the next major version.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Total

2

Last Release

60d ago

Major Versions

0.1.0 → 1.0.02026-05-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ecccf9003c061847e877eeea3bdf1b382f6f9dbb11d33112d6b2740bf0533f9?d=identicon)[sirix777](/maintainers/sirix777)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sirix-mezzio-routing-contracts/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[cakephp/authentication

Authentication plugin for CakePHP

1214.1M107](/packages/cakephp-authentication)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.2k](/packages/typo3-cms-core)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[typo3/cms-adminpanel

TYPO3 CMS Admin Panel - The Admin Panel displays information about your site in the frontend and contains a range of metrics including debug and caching information.

115.7M68](/packages/typo3-cms-adminpanel)[flarum/core

Delightfully simple forum software.

211.4M2.4k](/packages/flarum-core)

PHPackages © 2026

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