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

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

pierre/router
=============

A router package for your project

1.1.3(3y ago)033MITPHPPHP &gt;=7.0.0

Since Feb 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/pierrenoel/router)[ Packagist](https://packagist.org/packages/pierre/router)[ RSS](/packages/pierre-router/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (6)Used By (0)

Router PHP package documentation
================================

[](#router-php-package-documentation)

 [ ![](https://camo.githubusercontent.com/ec590ed3b18e79686dd269ba4b3f7788e485e07a08347b85620f8d5ef2e371a1/68747470733a2f2f736b696c6c69636f6e732e6465762f69636f6e733f693d706870) ](https://skillicons.dev)

The Router PHP package provides an easy-to-use routing system for PHP web applications. It allows developers to define routes for different HTTP methods such as GET, POST, DELETE, and PUT. Additionally, it supports the use of hidden input fields to simulate the DELETE, PUT, and PATCH HTTP methods.

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

[](#requirements)

The Router PHP package requires PHP 7.0 or higher.

features
--------

[](#features)

- Define routes for GET, POST, DELETE, and PUT HTTP methods
- Define routes with parameters

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

[](#installation)

To use the Router PHP package, you need to install it via Composer. Run the following command in your project directory:

```
composer require pierre/router
```

Usage
-----

[](#usage)

To use the Router, you need to create a new instance of the Router class:

```
// Require composer autoloader
require __DIR__ . '/vendor/autoload.php';

// Create Router instance
$router = new \Pierre\Router\Router();

// Define routes
// ...

// Run it!
```

Defining Routes
---------------

[](#defining-routes)

The Router supports four HTTP methods: GET, POST, DELETE, and PUT. You can define a route for each method using the following methods:

### GET

[](#get)

To define a GET route, use the get() method. The first parameter is the URL path, and the second parameter is a callback function that will be executed when the route is accessed:

```
$router->get('/', function() {
    return 'Hello World!';
});
```

### POST

[](#post)

To define a POST route, use the post() method.

```
$router->post('/', function() {
    return $_POST['name'];
});
```

### DELETE

[](#delete)

To define a DELETE route, use the delete() method.

```
$router->delete('/user/:id', function($id) {
    return 'User ' . $id . ' deleted';
});
```

### PUT

[](#put)

To define a PUT route, use the put() method.

```
$router->put('/user/:id', function($id) {
    return 'User ' . $id . ' updated';
});
```

Executing the Router
--------------------

[](#executing-the-router)

After defining your routes, you need to execute the Router using the run() method:

```
$router->run();
```

Simulating DELETE, PUT, and PATCH Methods
-----------------------------------------

[](#simulating-delete-put-and-patch-methods)

To simulate the DELETE, PUT, and PATCH HTTP methods in a form, you need to include a hidden input field with the name \_method and the value of the desired method. The Router will detect this input field and use the specified method for the request.

### Delete example

[](#delete-example)

```

```

### Put example

[](#put-example)

```

```

### Passing Parameters

[](#passing-parameters)

You can pass parameters to your routes using the following syntax:

```
$name = "Pierre";
$router->get('/hello', function() use ($name) {
    return "Hello {$name}!}";
});
```

License
-------

[](#license)

The Router PHP package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

5

Last Release

1109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cbcee2140b60aa5f62ff1c6df3ef43b7251770f624b3f33ef4e37183022d052?d=identicon)[pierrenoel](/maintainers/pierrenoel)

---

Top Contributors

[![pierrenoel](https://avatars.githubusercontent.com/u/46715488?v=4)](https://github.com/pierrenoel "pierrenoel (6 commits)")

---

Tags

routerroutingrouterrouting

### Embed Badge

![Health badge](/badges/pierre-router/health.svg)

```
[![Health](https://phpackages.com/badges/pierre-router/health.svg)](https://phpackages.com/packages/pierre-router)
```

###  Alternatives

[bramus/router

A lightweight and simple object oriented PHP Router

1.1k490.5k55](/packages/bramus-router)

PHPackages © 2026

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