PHPackages                             jonahh/omniroute - 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. [Framework](/categories/framework)
4. /
5. jonahh/omniroute

ActiveLibrary[Framework](/categories/framework)

jonahh/omniroute
================

A simple framework to make URL Routing in PHP easier

v1.2.11(11mo ago)025MITPHP

Since Aug 26Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/Jonah987654321/OmniRoute)[ Packagist](https://packagist.org/packages/jonahh/omniroute)[ RSS](/packages/jonahh-omniroute/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (18)Used By (0)

OmniRoute
=========

[](#omniroute)

**OmniRoute** is a lightweight, flexible PHP routing library designed to simplify the management of routes in your PHP applications. It allows you to define routes, handle URL parameters with regular expressions, and manage error callbacks for common HTTP response codes.

Features
--------

[](#features)

- **Route Registration**: Easily register routes with specific HTTP methods and callbacks.
- **Prefix Support**: Apply a prefix to a group of routes to organize and manage them efficiently.
- **Error Handling**: Register custom callbacks for handling `404 Not Found` and `405 Method Not Allowed` errors.
- **Regular Expression Arguments**: Support for dynamic URL parameters using regular expressions.
- **Sub-Router Integration**: Include and register routes from external files for better modularization.

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

[](#installation)

```
composer require jonahh/omniroute

```

Usage
-----

[](#usage)

### Basic Route Registration

[](#basic-route-registration)

You can register a simple route by calling the `add` method:

```
use OmniRoute\Router;
require __DIR__.'/vendor/autoload.php';

Router::add('/home', function() {
    echo "Welcome to the homepage!";
});
```

### Route with Parameters

[](#route-with-parameters)

To create a route with dynamic parameters, use placeholders wrapped in ``:

```
Router::add('/user/', function($id) {
    echo "User ID: " . $id;
});
```

### Prefixing Routes

[](#prefixing-routes)

You can group routes under a common prefix:

```
Router::registerPrefix('/api/v1');

Router::add('/users', function() {
    echo "Users endpoint";
});
```

All routes added after setting a prefix will automatically include it.

### Registering Sub-Routers

[](#registering-sub-routers)

For better modularization, you can load routes from external files:

```
Router::registerSubRouter('path/to/routes.php');
```

### Setting allowed methods

[](#setting-allowed-methods)

You can set what methods are allowed for routes to be called:

```
Router::add('/api/post-only', function() {
    echo json_encode(["data"=>$data]);
}, ["POST"]);
```

### Handling Errors

[](#handling-errors)

You can register custom error callbacks for `404` and `405` errors:

```
Router::registerErrorCallback(OMNI_404, function($path) {
    echo "Error 404: The path $path was not found.";
});

Router::registerErrorCallback(OMNI_405, function($path, $method) {
    echo "Error 405: The method $method is not allowed for $path.";
});
```

### Running the Router

[](#running-the-router)

Finally, to execute the router and handle incoming requests, call the `run` method:

```
Router::run();
```

License
-------

[](#license)

This package is open-source and available under the MIT License.

Author
------

[](#author)

This package is developed by [Jonah](https://github.com/Jonah987654321/)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance52

Moderate activity, may be stable

Popularity7

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

Recently: every ~34 days

Total

17

Last Release

332d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4af3b0e398838b02b54a9c0c8c3d2e06ca452a612843c0035ab04d646e5e609c?d=identicon)[Jonah987654321](/maintainers/Jonah987654321)

---

Top Contributors

[![Jonah987654321](https://avatars.githubusercontent.com/u/82569523?v=4)](https://github.com/Jonah987654321 "Jonah987654321 (30 commits)")

### Embed Badge

![Health badge](/badges/jonahh-omniroute/health.svg)

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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