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

Abandoned → [michel/router](/?search=michel%2Frouter)ArchivedLibrary

phpdevcommunity/php-router
==========================

A versatile and efficient PHP routing solution designed to streamline route management within PHP applications.

3.1.0(7mo ago)278404[1 issues](https://github.com/michelphp/php-router/issues)MITPHPPHP &gt;=7.4

Since Apr 22Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/michelphp/php-router)[ Packagist](https://packagist.org/packages/phpdevcommunity/php-router)[ RSS](/packages/phpdevcommunity-php-router/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (4)Versions (14)Used By (0)

> ⚠️ **Abandoned package**
>
> This package is abandoned and no longer maintained.
> The author suggests using **[michel/router](https://github.com/michelphp/router)** instead.

PHP Router
==========

[](#php-router)

PHP Router is a simple and efficient routing library designed for PHP applications. It provides a straightforward way to define routes, handle HTTP requests, and generate URLs. Built with PSR-7 message implementation in mind, it seamlessly integrates with PHP applications.

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

[](#installation)

You can install PHP Router via Composer. Just run:

### Composer Require

[](#composer-require)

```
composer require phpdevcommunity/php-router

```

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

[](#requirements)

- PHP version 7.4 or above
- Enable URL rewriting on your web server
- Optional: PSR-7 HTTP Message package (e.g., guzzlehttp/psr7)

Usage
-----

[](#usage)

1. **Define Routes**: Define routes using the `Route` class provided by PHP Router.
2. **Initialize Router**: Initialize the `Router` class with the defined routes.
3. **Match Requests**: Match incoming HTTP requests to defined routes.
4. **Handle Requests**: Handle matched routes by executing appropriate controllers or handlers.
5. **Generate URLs**: Generate URLs for named routes.

Example
-------

[](#example)

```
