PHPackages                             memran/marwa-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. memran/marwa-router

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

memran/marwa-router
===================

Attribute + fluent routing over league/route with PSR-7/15/16 support.

v1.3.0(1mo ago)0831MITPHPPHP ^8.2CI passing

Since Sep 9Pushed 1mo agoCompare

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

READMEChangelogDependencies (18)Versions (5)Used By (1)

Marwa Router
============

[](#marwa-router)

[![CI](https://camo.githubusercontent.com/fac6769456b28b57402e8bb3194ce6fedc5e779fb06c1eddd602bc5384457ab1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d656d72616e2f6d617277612d726f757465722f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/memran/marwa-router/actions/workflows/ci.yml)[![PHPUnit](https://camo.githubusercontent.com/7cdf1ce5297137f00391e405cacb061ff29d5b8bf0f6ad4356bbebdce0f6c7e1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d31312e782d304539463645)](#development)[![PHPStan](https://camo.githubusercontent.com/fad8eae8018ef2bd4a6461314cd3fd51f55efbccf13f24ad1a108dfae4c10c4b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d322e782d364234364331)](#development)[![Packagist Version](https://camo.githubusercontent.com/03d840b09e6ab6d984dd61e72840aa0180b9973b96165e6921e2f19c5c3078e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656d72616e2f6d617277612d726f75746572)](https://packagist.org/packages/memran/marwa-router)[![PHP Version](https://camo.githubusercontent.com/261081ad7081ec792a7a5c3061b8d4e78a29640d8fa9da05cd7144fbfce95b74/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d656d72616e2f6d617277612d726f75746572)](https://packagist.org/packages/memran/marwa-router)[![Packagist Downloads](https://camo.githubusercontent.com/e95e8c4e923e777c0e1f93e33f61deba07a44c3223b7c6f80b22bdf42e342e2d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d656d72616e2f6d617277612d726f75746572)](https://packagist.org/packages/memran/marwa-router)[![License](https://camo.githubusercontent.com/8195d5c1d0517f7c5bc9cd7268fabfebefc48766ca9648c7f6847f98f5013398/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d656d72616e2f6d617277612d726f75746572)](LICENSE)

Marwa Router is a framework-agnostic routing library for PHP 8.2+ built on top of `league/route`. It combines PHP 8 attributes, a fluent route builder, PSR-7 request handling, PSR-15 middleware integration, and small convenience helpers for responses, input access, route inspection, and signed URLs.

Why Marwa Router
----------------

[](#why-marwa-router)

- Keep route definitions close to controller code with native PHP attributes
- Register routes fluently when you want explicit bootstrap logic
- Stay compatible with PSR-7, PSR-15, PSR-16, and PSR-11 components
- Attach middleware, host constraints, parameter rules, and throttling per route or controller
- Use small utilities for JSON/HTML responses, request input, URL generation, and route inspection

Stability
---------

[](#stability)

This package follows semantic versioning for its documented public API under `src/`. Backward-compatible additions may appear in minor releases. Behavioral breaks, constructor signature changes, or renamed public methods belong in major releases and should be called out in [`CHANGELOG.md`](CHANGELOG.md).

Features
--------

[](#features)

- Attribute routing with `#[Route]`, `#[Prefix]`, `#[Where]`, `#[Domain]`, `#[UseMiddleware]`, `#[GroupMiddleware]`, and `#[Throttle]`
- Fluent route registration with grouping, naming, middleware, domain, constraints, and throttling
- Optional trailing-slash matching
- Direct route mapping with `map()` and a fluent registrar for grouped definitions
- PSR-11 container integration for controller and middleware resolution
- PSR-16-backed throttling middleware
- Optional PSR-3 logging hooks for dispatch failures and throttling events
- Trusted proxy and trusted host handling in `RequestFactory`
- Metadata cache and compiled route bootstrap cache for faster startup
- Response helpers for JSON, HTML, text, redirects, cookies, and downloads
- Input helpers for query params, parsed body, route params, headers, cookies, and files
- Route registry inspection with `bin/routes-dump.php`
- Signed URL generation and verification

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

[](#requirements)

- PHP 8.2 or newer
- Composer

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

[](#installation)

```
composer require memran/marwa-router
```

Quick Start
-----------

[](#quick-start)

```
