PHPackages                             unl/reg-exp-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. unl/reg-exp-router

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

unl/reg-exp-router
==================

v0.1.3(9mo ago)8133[2 issues](https://github.com/unl/RegExpRouter/issues)PHP

Since Oct 8Pushed 9mo ago5 watchersCompare

[ Source](https://github.com/unl/RegExpRouter)[ Packagist](https://packagist.org/packages/unl/reg-exp-router)[ RSS](/packages/unl-reg-exp-router/feed)WikiDiscussions master Synced today

READMEChangelog (3)DependenciesVersions (4)Used By (0)

RegExpRouter
============

[](#regexprouter)

Introduction
------------

[](#introduction)

RegExpRouter is a php router system that routes clean URLs based on regular expressions and support PSR-0 complient projects.

**Possible Options for a new Router:**
$options = array(
‘baseURL’=&gt;’yoururl’, //required: the full url:
‘srcDir’=&gt;’yourSrcDir’ //Only required if you want to scan your models. **Must** be a full system path to your source directory.
);

Methods of routing:
-------------------

[](#methods-of-routing)

1\. **Scanning**

The router will scan though your models and load routes. You will need a file called Routes.php within each of your model’s directories (ie: project/exampleModel/Routes.php). This Routes.php file must extend RegExpRouter\\RoutesInterface and define all of the routes for that model.

For each Model that has a route, you will need to place a file named “Routes” within that class, which implements RegExpRouter\\RoutesInterface and define the regex routes for the model.

Routes are defined as an array of routes. And example route would look like this: $routes = array(array(‘yourRegex’ =&gt; ‘referenceModel’), array(‘moreRegex’ =&gt; ‘anotherModel’));
The reference model should be the name of a class within the current model **without** it’s namespace. The namespace will be added to it automatically.

**Here is some example code for scanning your models:**

$options = array(‘baseURL’=&gt;’yoururl’, ‘srcDir’=&gt;’yourSrcDir’);
$router = new RegExpRouter\\Router($options);
$router→route($*SERVER\[‘REQUEST\_URI’\], $*GET);

2\. **User Defined Mapping**

You can compile the array of regex to model mapping yourself and call the RegExpRouter→setRoutes(array) method:

**Here is some example code for using your own mapping:**

Routes are the same as the scaning method, except you should **always** define the fulll namesapce to the class within the model that you are referencing.

$options = array(‘baseURL’=&gt;’yoururl’);
$router = new RegExpRouter\\Router($options);
$router→setRoutes(array(‘/^home$/i’ =&gt; ‘ExampleProject\\ExampleModel\\View’));
$router→route($*SERVER\[‘REQUEST\_URI’\], $*GET);

Example
-------

[](#example)

To view the very simple Example application in the Example folder to get a better feel of how it works.

To set up the example application you will have to do the following:
1\) Copy the config.sample.php to a new file called config.inc.php in the same folder.
2\) Change the Example\\Controller::$url in config.inc.php to a url that works with your setup.
3\) Copy the sample.htaccess file to a new file called .htaccess in the same folder.
4\) In .htaccess change the RewriteBase path to work with your setup.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance51

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.7% 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 ~1970 days

Total

3

Last Release

292d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b0e9f3e47cd4feefc620023b32baf092a2785e8092b3d2b49a79608d9c0ac80?d=identicon)[mfairchild365](/maintainers/mfairchild365)

![](https://www.gravatar.com/avatar/711ba9e9aa047be2d40621de4098e752c23ee30a9b95c95941440e4aa0fed93d?d=identicon)[ericras](/maintainers/ericras)

![](https://www.gravatar.com/avatar/6e031eb579cc69ba56d0e76d472cfe212a93ea180852d524e37ab12f0d12b02b?d=identicon)[macburgee1](/maintainers/macburgee1)

![](https://www.gravatar.com/avatar/1d20810c105e3896f6350ffdf288f8537cf2659284b016870a1f3db92a434c16?d=identicon)[jsturek8](/maintainers/jsturek8)

![](https://www.gravatar.com/avatar/668b4bc812e41e1fda204a60c369f696cf00d4818f3e2a22966e3b34f47f68b9?d=identicon)[tommyneu](/maintainers/tommyneu)

---

Top Contributors

[![mfairchild365](https://avatars.githubusercontent.com/u/498678?v=4)](https://github.com/mfairchild365 "mfairchild365 (55 commits)")[![saltybeagle](https://avatars.githubusercontent.com/u/92284?v=4)](https://github.com/saltybeagle "saltybeagle (11 commits)")[![kabel](https://avatars.githubusercontent.com/u/675956?v=4)](https://github.com/kabel "kabel (2 commits)")[![tommyneu](https://avatars.githubusercontent.com/u/57959550?v=4)](https://github.com/tommyneu "tommyneu (1 commits)")

### Embed Badge

![Health badge](/badges/unl-reg-exp-router/health.svg)

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

###  Alternatives

[ericmann/wp-session-manager

Prototype session management for WordPress.

27123.6k1](/packages/ericmann-wp-session-manager)[irazasyed/docgen

Streamline your Laravel package development with automatic facade documentation using Docgen for Laravel

233.8k10](/packages/irazasyed-docgen)

PHPackages © 2026

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