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

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

spiffy/spiffy-route
===================

Spiffy\\Route is a light-weight, HHVM compatible, and dependency free router library.

1.0.0-alpha(11y ago)359511BSD-3-ClausePHPPHP &gt;=5.4

Since Jul 17Pushed 11y ago2 watchersCompare

[ Source](https://github.com/spiffyjr/spiffy-route)[ Packagist](https://packagist.org/packages/spiffy/spiffy-route)[ RSS](/packages/spiffy-spiffy-route/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (2)Used By (1)

Spiffy\\Route
=============

[](#spiffyroute)

[![Build Status](https://camo.githubusercontent.com/892c2fa5de554549f3d22f42db01daea6274c7f31357fad95db9ecd7375259b3/68747470733a2f2f7472617669732d63692e6f72672f7370696666796a722f7370696666792d726f7574652e737667)](https://travis-ci.org/spiffyjr/spiffy-route)[![Code Coverage](https://camo.githubusercontent.com/860b0cde17aa48a663432d356c4c02c2e5c1cdfbcfe554adc7ee1703df268093/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696666796a722f7370696666792d726f7574652f6261646765732f636f7665726167652e706e673f733d31623764636139643036623166643733323961366266396331306665666135353264346265383633)](https://scrutinizer-ci.com/g/spiffyjr/spiffy-route/)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b39862179d5db524e49e2c0e36a2afe60eff7aa0349cbdf934a0e1633615d212/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696666796a722f7370696666792d726f7574652f6261646765732f7175616c6974792d73636f72652e706e673f733d62336133343366633361326231656137666432343434393965323965633238643731363933666132)](https://scrutinizer-ci.com/g/spiffyjr/spiffy-route/)

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

[](#installation)

Spiffy\\Route can be installed using composer which will setup any autoloading for you.

`composer require spiffy/spiffy-route`

Additionally, you can download or clone the repository and setup your own autoloading.

Adding routes
-------------

[](#adding-routes)

```
use Spiffy\Route\Router;

$router = new Router();

// Basic route with name
$router->add('foo', '/foo');
// matches /foo

// Basic route with no name
$router->add(null, '/foo');
// matches /foo

// Route with tokens
$router->add('foo', '/foo/{name}');
// matches /foo/bar

// Router with optional tokens
$router->add('foo', '/foo{/name?}');
// matches /foo or /foo/bar

// Router with tokens and constraints
$router->add('foo', '/foo/{id:\d+}-{slug}');
// matches /foo/1-bar but not /foo/baz-bar

// The kitchen sink
$router->add('foo', '/foo/{id:\d+}{-slug?:[a-zA-Z-_]+}');
// matches /foo/1, /foo/1-bar, /foo/1-BaR
// does not match /foo/1-2
```

Assembling named routes to url's
--------------------------------

[](#assembling-named-routes-to-urls)

```
use Spiffy\Route\Router;

$router = new Router();
$router->add('foo', '/foo');

// outputs '/foo'
echo $router->assemble('foo');

$router->add('foo', '/foo/{id:\d+}{-slug?:[a-zA-Z-_]+}');

// outputs '/foo/1'
echo $router->assemble('foo', ['id' => 1]);

// outputs '/foo/1-bar'
echo $router->assemble('foo', ['id' => 1, 'slug' => 'bar']);
```

Matching routes
---------------

[](#matching-routes)

```
use Spiffy\Route\Router;

$router = new Router();
$router->add('foo', '/foo');

// result is NULL
echo $router->match('/bar');

// result is an instance of Spiffy\Route\RouteMatch
$match = $router->match('/foo');

// output is 'foo'
echo $match->getName();

$router->add('bar', '/bar/{id}');

// result is an instance of Spiffy\Route\RouteMatch
$match = $router->match('/bar/1');

// output is 'bar'
echo $match->getName();

// output is '1'
echo $match->get('id');

// you can also have defaults for params that may not exist (output is 'foo')
echo $match->get('does-not-exist', 'foo');
```

Default route parameters
------------------------

[](#default-route-parameters)

```
use Spiffy\Route\Router;

$router = new Router();
$router->add('foo', '/foo{/id?}', ['defaults' => ['id' => 1, 'controller' => 'foo-controller']]);

$match = $router->match('/foo/1234');

// output is '1234'
echo $match->get('id');

$match = $router->match('/foo');

// output is '1'
echo $match->get('id');

// output is 'foo-controller'
echo $match->get('controller');
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.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

Unknown

Total

1

Last Release

4315d ago

### Community

Maintainers

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

---

Top Contributors

[![spiffyjr](https://avatars.githubusercontent.com/u/2760734?v=4)](https://github.com/spiffyjr "spiffyjr (6 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[bigwhoop/sentence-breaker

Sentence boundary disambiguation (SBD) - or sentence breaking - library written in PHP.

42132.3k](/packages/bigwhoop-sentence-breaker)[j0k3r/graby-site-config

Graby site config files

23365.8k3](/packages/j0k3r-graby-site-config)

PHPackages © 2026

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