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

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

marcosdipaolo/router
====================

A PHP Router package

1.2(3mo ago)056MITPHPPHP &gt;=8.2

Since Jan 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/marcosdipaolo/router)[ Packagist](https://packagist.org/packages/marcosdipaolo/router)[ GitHub Sponsors](https://github.com/marcosdipaolo)[ RSS](/packages/marcosdipaolo-router/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (6)Versions (17)Used By (0)

MDP Router
==========

[](#mdp-router)

A modern, production-ready PHP router library built with PHP 8.2+ and attribute-based routing. It provides a clean, expressive API for defining routes, handling middleware, and managing HTTP requests and responses.

Features
--------

[](#features)

- ✨ **Attribute-Based Routing**: Define routes using modern PHP 8 attributes
- 🎯 **Dynamic Route Parameters**: Support for path parameters like `/users/{id}`
- 🔄 **Middleware Pipeline**: Built-in middleware support with global and route-specific middleware
- ⚡ **Route Caching**: Cache compiled routes for optimal performance
- 🌐 **Full HTTP Support**: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
- 🔀 **Route Groups**: Organize related routes under common prefixes and middleware
- 🔗 **Reverse Routing**: Generate URLs from route names and parameters
- 📨 **Method Spoofing**: Support for `_method` parameter to simulate HTTP verbs in forms
- 🛡️ **Security Headers**: Built-in CORS and security header support
- 📝 **Request/Response Objects**: Clean abstractions for HTTP requests and responses
- 🧪 **Comprehensive Testing**: Full test suite for all features

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

[](#installation)

```
composer require marcosdipaolo/router
```

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

[](#quick-start)

### 1. Setup Your Entry Point

[](#1-setup-your-entry-point)

Create an `index.php` file at your project root:

```
