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

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

omarlon/php-router
==================

A PHP router with a syntax like a Laravel

01PHP

Since May 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/marlon33/PHPRouter)[ Packagist](https://packagist.org/packages/omarlon/php-router)[ RSS](/packages/omarlon-php-router/feed)WikiDiscussions Master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Router
==========

[](#php-router)

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

[](#installation)

Install using composer or include Router.php. For cleaner urls use the following .htaccess file:

```

	Options +FollowSymLinks
	RewriteEngine On

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.*)$ index.php/$1 [L]

```

Example
-------

[](#example)

Registering a route that responds to "GET /":

```
Route::get('/', function()
{
	return "Hello World!";
});

```

Registering a route that is valid for any HTTP verb (GET, POST, PUT, and DELETE):

```
Route::any('/', function()
{
	return "Hello World!";
});

```

Registering routes for other request methods:

```
Route::post('user', function()
{
	//
});

Route::put('user/(:num)', function($id)
{
	//
});

Route::delete('user/(:num)', function($id)
{
	//
});

```

Registering a single URI for multiple HTTP verbs:

```
Route::register(array('GET', 'POST'), $uri, function()
{
	//
});

```

Registering a route that is only valid for HTTPS requests:

```
Route::secure('GET', '/', function()
{
	//
});

```

Wildcards
---------

[](#wildcards)

Forcing a URI segment to be any digit:

```
Route::get('user/(:num)', function($id)
{
	//
});

```

Allowing a URI segment to be any alpha-numeric string:

```
Route::get('post/(:any)', function($title)
{
	//
});

```

Catching the remaining URI without limitations:

```
Route::get('files/(:all)', function($path)
{
	//
});

```

Allowing a URI segment to be optional:

```
Route::get('page/(:any?)', function($page = 'index')
{
	//
});

```

Controller Routing
------------------

[](#controller-routing)

Controllers provide another way to manage your application logic. It is important to be aware that all routes must be explicitly defined, including routes to controllers. This means that controller methods that have not been exposed through route registration cannot be accessed. It's possible to automatically expose all methods within a controller using controller route registration.

Registering the "home" controller with the Router:

```
Route::controller('home');

```

Registering several controllers with the router:

```
Route::controller(array('dashboard.panel', 'admin'));

```

This convention is similar to that employed by CodeIgniter and other popular frameworks, where the first segment is the controller name, the second is the method, and the remaining segments are passed to the method as arguments. If no method segment is present, the "index" method will be used.

This routing convention may not be desirable for every situation, so you may also explicitly route URIs to controller actions using a simple, intuitive syntax.

Registering a route that points to a controller action:

```
Route::get('welcome', 'home@index');

```

Extras
------

[](#extras)

Get your site base URL:

```
Router::base();

```

Get the current URI:

```
Router::uri();

```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/815e42473ce96082344da076945e73c118fb4bc86961a191b3ad6518a2a7dff5?d=identicon)[oMarlon](/maintainers/oMarlon)

---

Top Contributors

[![marlon33](https://avatars.githubusercontent.com/u/41172965?v=4)](https://github.com/marlon33 "marlon33 (1 commits)")

### Embed Badge

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

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

###  Alternatives

[novactive/ezseobundle

Novactive eZ SEO Bundle is an Ibexa Platform bundle for SEO simplications. metas, sitemaps, robots.txt, etc.

26252.0k2](/packages/novactive-ezseobundle)[b13/unlocalizedcrop

Disables cropping for translated records. Cropping of localized records are automatically taken from the original language

1449.2k](/packages/b13-unlocalizedcrop)

PHPackages © 2026

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