PHPackages                             dzentota/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dzentota/router

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dzentota/router
===============

Fast and flexible security aware router.

134PHP

Since Mar 25Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/dzentota/router)[ Packagist](https://packagist.org/packages/dzentota/router)[ RSS](/packages/dzentota-router/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

dzentota/router
===============

[](#dzentotarouter)

A high-performance, security-first PHP router with comprehensive PSR-15 middleware suite.

Features
--------

[](#features)

- **High Performance**: Optimized route matching with tree-based algorithm
- **Type Safety**: Strongly-typed route parameters with validation
- **PSR-15 Compliant**: Full middleware support with PSR-15 interface
- **Security First**: Built-in security middleware suite
- **Production Ready**: Comprehensive error handling and logging
- **Flexible**: Support for closures, controllers, and dependency injection

Security Middleware Suite
-------------------------

[](#security-middleware-suite)

The router includes a comprehensive security middleware suite designed to protect against common web vulnerabilities:

### 🔒 CSRF Protection

[](#-csrf-protection)

- Stateless and stateful protection strategies
- Cryptographically secure token generation
- HMAC-signed cookies for stateless protection
- PSR-16 cache integration for stateful protection

### 🛡️ Content Security Policy (CSP)

[](#️-content-security-policy-csp)

- Comprehensive CSP headers with nonce generation
- Configurable policy directives
- Report-only mode support
- Secure defaults for modern web applications

### 🌐 CORS Protection

[](#-cors-protection)

- Full CORS policy implementation
- Preflight request handling
- Origin, method, and header validation
- Credential support with security-first defaults

### 🕷️ Honeypot Protection

[](#️-honeypot-protection)

- Bot detection using hidden fields
- Timing analysis for request patterns
- Rate limiting with exponential backoff
- Comprehensive logging and monitoring

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

[](#quick-start)

### Installation

[](#installation)

```
composer require dzentota/router
```

### Basic Usage

[](#basic-usage)

```
