PHPackages                             benson/route-me - 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. benson/route-me

ActiveLibrary

benson/route-me
===============

A basic router for REST APIs with all compatible with all RESTFUL verbs

1.0.2(2y ago)49MITPHP

Since May 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bensonOSei/route-me)[ Packagist](https://packagist.org/packages/benson/route-me)[ RSS](/packages/benson-route-me/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

benson/router-me
================

[](#bensonrouter-me)

Description
-----------

[](#description)

Route-Me is a lightweight and flexible PHP router package for creating RESTful APIs. It supports route parameters, middleware, and PSR-7 request/response handling. Route-Me is built using the [PSR-7 HTTP message interfaces](https://www.php-fig.org/psr/psr-7/) and can be used with any PSR-7 implementation. It is also framework-agnostic and can be used with any PHP framework or standalone application. Route-Me is developed and maintained by [Benson Osei-Mensah](https://github/bensonOSei).

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

[](#installation)

To install Route-Me, run the following command in your project directory:

```
composer require benson/router-me
```

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Usage](#usage)
- [Contribution](#contribution)
- [License](#license)
- [Author](#author)

Features
--------

[](#features)

- Route Definition: Add routes to the router using the `addRoute()` method.
- Middleware: Apply middleware functions to specific routes or globally using the `withMiddleware()` method.
- Request Handling: Handle incoming requests by matching URL and HTTP method against defined routes.
- Error Handling: Handle 404 Not Found scenarios and custom error handling logic.
- Route Parameters: Support for route parameters defined within the URL pattern.
- Flexible Callbacks: Use closures or class methods as callback functions.
- PSR-7 Support: Built-in support for JSON request/response handling.

Usage
-----

[](#usage)

To use Route-Me in your project, follow these steps:

1. Import the composer autoloader into your PHP file:

    ```
    require_once 'vendor/autoload.php';
    ```
2. Create a new instance of the Router class:

    ```
    $router = new Router();
    ```
3. Add routes to the router using the `addRoute()` method:

    ```
    $router->get('/users', function () {
        // Handle GET request to /users
    });

    // Add class method as callback
    $router->addRoute('GET', '/users', "App\Controllers\UserController@index");

    // Add route parameters
    $router->addRoute('GET', '/users/{id}', function ($id) {
        // Handle GET request to /users/{id}
    });

    // Add middleware
    $router->addRoute(
        'GET', // HTTP method
        '/user/{id}', // URL pattern
        'App\Controllers\UserController@show', // Callback function
        'App\Middleware\Authenticate@handle' // Middleware function
        );

        // Add middleware to all routes
        $router->withMiddleware('App\Middleware\Authenticate@handle');

    $router->post('/users', function () {
        // Handle POST request to /users
    });
    ```
4. Handle incoming requests by calling the `run()` method:

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

Contribution
------------

[](#contribution)

Contributions are welcome! To contribute to Route-Me, follow these steps:

1. Fork the repository.
2. Create a new branch.

    ```
    git checkout -b your-branch-name
    ```
3. Make your changes.
4. Commit your changes and push them to your branch. Make sure to add a clear commit message and include any relevant documentation updates. Since Route-Me follows the [PSR-2 coding standards](https://www.php-fig.org/psr/psr-2/), please ensure that your code adheres to these standards. If you are not sure, you can use the [PHP Coding Standards Fixer](https://cs.symfony.com/)

    ```
    git add .
    git commit -m "your commit message"
    git push origin your-branch-name
    ```
5. Submit a pull request. Please ensure that you adhere to the coding standards and write clear commit messages.

License
-------

[](#license)

Route-Me is open-source software released under the MIT License. See [LICENSE](./LICENSE) for details.

Author
------

[](#author)

Route-Me is developed and maintained by [Benson Ose-Mensah](https://github.com/bensonOSei).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

3

Last Release

1034d ago

### Community

Maintainers

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

---

Top Contributors

[![bensonOSei](https://avatars.githubusercontent.com/u/53924872?v=4)](https://github.com/bensonOSei "bensonOSei (16 commits)")

### Embed Badge

![Health badge](/badges/benson-route-me/health.svg)

```
[![Health](https://phpackages.com/badges/benson-route-me/health.svg)](https://phpackages.com/packages/benson-route-me)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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