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

AbandonedArchivedLibrary[Framework](/categories/framework)

gears/router
============

Laravel Router Standalone

v0.6.6(11y ago)244.8k7MITPHP

Since Sep 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/phpgearbox/router)[ Packagist](https://packagist.org/packages/gears/router)[ Docs](https://github.com/phpgearbox/router)[ RSS](/packages/gears-router/feed)WikiDiscussions master Synced 1w ago

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

> Looking for maintainers, I no longer do much if any PHP dev, I have moved on, mostly work in dotnet core, node.js &amp; golang these days. If anyone is keen to take over these projects, get in touch -

The Router Gear
===============

[](#the-router-gear)

[![Build Status](https://camo.githubusercontent.com/d4e19d56b5bd23a3410da1a64483ace4a78132c54cc6fe1c04febcd1aa4111e1/68747470733a2f2f7472617669732d63692e6f72672f70687067656172626f782f726f757465722e737667)](https://travis-ci.org/phpgearbox/router)[![Latest Stable Version](https://camo.githubusercontent.com/ff2e4f8e11cdd5ecc837857f718105d486d08b1be6f44909f56f5e8c62c49d61/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f726f757465722f762f737461626c652e737667)](https://packagist.org/packages/gears/router)[![Total Downloads](https://camo.githubusercontent.com/b5c59a374700db763c3f9ef057157a5426f316a2615a11e74f97276fe685d84d/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f726f757465722f646f776e6c6f6164732e737667)](https://packagist.org/packages/gears/router)[![License](https://camo.githubusercontent.com/fe664e452672974b4edb81949ad52e1ef7456ceb2dea545bffaa449a8f7eb67e/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f726f757465722f6c6963656e73652e737667)](https://packagist.org/packages/gears/router)

**Laravel Router Standalone**

Okay so by now hopefully you have heard of [Laravel](http://laravel.com/), the PHP framework that just makes things easy. So first things first full credit goes to [Taylor Otwell](https://github.com/taylorotwell) for the Router API.

How to Install
--------------

[](#how-to-install)

Installation via composer is easy:

```
composer require gears/router:*

```

How to Use
----------

[](#how-to-use)

In your *legacy* - non Laravel application. You can use the Laravel Router API like so:

```
// Make sure you have composer included
require('vendor/autoload.php');

// Install the gears router component
$router = new Gears\Router();
$router->routesPath = '/file/path/to/my/routes';
$router->dispatch();

// At this point execution will not continue. The router will either output
// the results from a route and exit or it will output a 404 and then exit.
```

The `/file/path/to/my/routes` can either be a routes php file. eg: `/file/path/to/my/routes.php` this file would look just like any *routes.php* file you would find in any other Laravel App.

**OR**

The path can be to a folder containing lots of route files. The files will be included automatically for you and added to the router. This is my prefered solution.

> A little aside: In my Laravel Apps I place some code, similar to what is in this Router that loops through a *routes* folder inside my *app* dir. I place one route definition per file. I rarely use Controllers. I name each route file like *search-{postcode}.GET.php* which contains: `Route::get('/search/{postcode}', function($postcode){});`It makes for a very fast prototyping development life cycle.

An Example Route
----------------

[](#an-example-route)

So just like a Laravel Route, see: Here is an example route file.

```
Route::get('/', function()
{
	return 'I Am Groot';
});
```

**Class Alias**Behind the scenes when you call `dispatch()` we automatically create a new class alias called `Route`, this sets up the normal public API you are used to. However if the class `Route` is already in existence. We also alias ourselves to `Gears\Route`.

The 404 Error
-------------

[](#the-404-error)

Out of the box we have built in a simple and clean looking 404 error page. Credits go to:  Thank Guys.

However if you wish to overide the 404 content the router returns. The instalation of the router might look like:

```
$router = new Gears\Router();
$router->routesPath = '/file/path/to/my/routes';
$router->notFound = 'Custom 404 HTML';
$router->dispatch();
```

**The 404 Exception**If you set the 404 parameter to a boolean value of *false*. Then we will simply re-throw the 404 exception, which is an instance of:

```
Symfony\Component\HttpKernel\Exception\NotFoundHttpException

```

You can then deal with this yourself. An example use case might be to have multiple routers. Which then could provide a HMVC type setup.

Exit On Complete
----------------

[](#exit-on-complete)

For most setups you will probably want the execution of PHP to stop after the router has done it's thing and sent the response. However if for whatever reason you don't want this, perhaps some sort of output buffering or something. The instalation of the router might look like:

```
$router = new Gears\Router();
$router->routesPath = '/file/path/to/my/routes';
$router->exitOnComplete = false;
$router->dispatch();
```

So now for the why?
-------------------

[](#so-now-for-the-why)

While laravel is so awesomely cool and great. If you want to pull a feature out and use it in another project it can become difficult. Firstly you have to have an innate understanding of the [IoC Container](http://laravel.com/docs/ioc).

You then find that this class needs that class which then requires some other config variable that is normally present in the IoC when run inside a normal Laravel App but in your case you haven't defined it and don't really want to define that value because it makes no sense in your lets say *legacy*application.

Perfect example is when I tried to pull the session API out to use in wordpress. It wanted to know about a `booted` method, which I think comes from `Illuminate\Foundation\Application`. At this point in time I already had to add various other things into the IoC to make it happy and it was the last straw that broke the camels back, I chucked a coders tantrum, walked to the fridge, grabbed another Redbull and sat back down with a new approach.

The result is this project.

---

Developed by Brad Jones -

###  Health Score

34

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

13

Last Release

4258d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2754772?v=4)[Brad Jones](/maintainers/brad-jones)[@brad-jones](https://github.com/brad-jones)

---

Top Contributors

[![brad-jones](https://avatars.githubusercontent.com/u/2754772?v=4)](https://github.com/brad-jones "brad-jones (5 commits)")

---

Tags

laravelrouterstandalone

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k16.3M146](/packages/laravel-pulse)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.6k26.0M750](/packages/laravel-boost)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M206](/packages/laravel-mcp)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k30.2M156](/packages/laravel-cashier)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9922.4M142](/packages/roots-acorn)

PHPackages © 2026

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