PHPackages                             lgrdev/simplerouter - 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. lgrdev/simplerouter

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

lgrdev/simplerouter
===================

A very simple php router

1.0.1(2y ago)016MITPHPPHP &gt;=8.1.0

Since Oct 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/lgrdev/SimpleRouter)[ Packagist](https://packagist.org/packages/lgrdev/simplerouter)[ RSS](/packages/lgrdev-simplerouter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

SimpleRouter
============

[](#simplerouter)

A very simple router for GET, POST, PUT, DELETE methods

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Latest Version](https://camo.githubusercontent.com/5aa677bc823a7b237e233a109adf051a6e762e4cba393ea6be3c3711d12e272f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c67726465762f73696d706c65726f757465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/lgrdev/simplerouter/releases)

Install
-------

[](#install)

```
$ composer require lgrdev/simplerouter

```

Usage
-----

[](#usage)

```
$myrouter = new SimpleRouter();

// add route to home page
$myrouter->addGet('/', function () {   echo 'Hello, I\'m the home page'; } );

// route with a parameter
$myrouter->addGet('/book/{id}', function ($id) {   echo 'Hello, book #' . $id; } );

// route with a parameter id with format control
$myrouter->addGet('/book/{id:[0-9a-f]+}', function ($id) {   echo 'Hello, book #' . $id; } );

// route with a parameter and an optional parameter id2
$myrouter->addGet('/user/{id1}/{?id2}', function ($id1, $id2 = null) {   echo 'Hello User ' . $id; } );

// add a route for the method DELETE
$myrouter->addDelete('/book/{id:[0-9a-f]+}',  function ($id) {   echo 'Delete book #' . $id; } );

// add a POST route
$myrouter->addPost('/book', function ($id) {   echo 'Post a new book #'; } );

// display page
$myrouter->run($_REQUEST['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Total

2

Last Release

929d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2cc9ce3a60e06129b9adfc770a48ff21ca3cccd7c65942763797641f57a74d4?d=identicon)[lgrdev](/maintainers/lgrdev)

---

Top Contributors

[![lgrdev](https://avatars.githubusercontent.com/u/38876661?v=4)](https://github.com/lgrdev "lgrdev (5 commits)")

---

Tags

phprouter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lgrdev-simplerouter/health.svg)

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

###  Alternatives

[typo3-contentblocks/contentblocks-reg-api

This API provides an easy and reliable way to register content blocks as standalone packages.

204.9k](/packages/typo3-contentblocks-contentblocks-reg-api)

PHPackages © 2026

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