PHPackages                             codeeverything/junction - 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. codeeverything/junction

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

codeeverything/junction
=======================

0.1(10y ago)122PHP

Since Mar 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/codeeverything/junction)[ Packagist](https://packagist.org/packages/codeeverything/junction)[ RSS](/packages/codeeverything-junction/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Junction
========

[](#junction)

### A simple PHP router

[](#a-simple-php-router)

Junction is a simple PHP router. Right now it's created as a personal project out of interest, but I plan to use it as the default router in my micro-RESTful PHP framework [Planck](https://www.github.com/codeeverything/planck-mvc).

Open source
-----------

[](#open-source)

Comments and suggestions welcome. This open source, so get forking and PRing if you want! :)

Tests
-----

[](#tests)

Junction comes with a complete set of tests.

You can run them with PHPUnit quite simply from your shell:

```
vendor/bin/phpunit

```

Example usage
-------------

[](#example-usage)

### Simple route

[](#simple-route)

Let's define a simple route, with only one path segment

```
// define the route
$this->router->add('GET /hello', function () {
    // just return a string for the application to then work on
    return 'Hello, world';
});

// ... more routes ...

// handle the request, matching routes if possible
$response = $this->router->handleRequest();
```

The first argument to the `add()` funciton is a string which starts with the HTTP verb to match on, followed by the path requested.

### Simple route with path variable

[](#simple-route-with-path-variable)

Junction allows you to simply define variables in your route, using a similar placeholder syntax to PDO queries on your DB

```
// define the route - with required variable "name"
$this->router->add('GET /hello/:name', function ($name) {
    // just return a string for the application to then work on
    return 'Hello, ' . $name;
});

// ... more routes ...

// handle the request, matching routes if possible
$response = $this->router->handleRequest();
```

The variable "name" is passed in as the first argument in your handling function.

### Simple route with optional path variable

[](#simple-route-with-optional-path-variable)

```
// define the route - with optional variable "name"
$this->router->add('GET /hello/:name?', function ($name) {
    // just return a string for the application to then work on
    $name = isset($name) ? $name : 'world';
    return 'Hello, ' . $name;
});

// ... more routes ...

// handle the request, matching routes if possible
$response = $this->router->handleRequest();
```

If the "name" is given then we can use it, but if it's omitted the route will still match and we can fall back on the string "world".

### Variable validation

[](#variable-validation)

You can validate the path variables in your route by providing a list of validation callbacks

```
$this->router->add('GET /hello/:name', [
    'name' => [
        function ($value) {
            // only accept short names
            return strlen($value) < 5;
        },
    ],
], function ($name) {
    return 'Hello, ' . $name;
});
```

Validation errors will raise an `Exception` detailing the variable that failed validation and the invalid value.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

3743d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9589226?v=4)[Code Everything](/maintainers/codeeverything)[@codeeverything](https://github.com/codeeverything)

---

Top Contributors

[![codeeverything](https://avatars.githubusercontent.com/u/9589226?v=4)](https://github.com/codeeverything "codeeverything (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codeeverything-junction/health.svg)

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

###  Alternatives

[kx1000/kwota-slownie

Kwota słownie

1018.3k1](/packages/kx1000-kwota-slownie)

PHPackages © 2026

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