PHPackages                             benjaco/highway - 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. benjaco/highway

ActiveLibrary[Framework](/categories/framework)

benjaco/highway
===============

Simple and fast PHP router

1.2.1(8y ago)039MITPHPPHP &gt;=5.5.0

Since Jun 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/benjaco/Highway)[ Packagist](https://packagist.org/packages/benjaco/highway)[ Docs](https://github.com/benjaco/Highway)[ RSS](/packages/benjaco-highway/feed)WikiDiscussions master Synced today

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

Highway - a fast, simple, lightweight http router for PHP
=========================================================

[](#highway---a-fast-simple-lightweight-http-router-for-php)

This php router is 25 times faster then slim3, but highway are not having advanced stuff like middleware, it's a pure php router

Its is flexible, ex. it's is possible to add code in the start of a group

A part of the speed reason is, this router is not collecting all routes before its run, is running as soon the route is defined, and if the url is not matching a specific group, then the groups callback won't be executed

Installing
----------

[](#installing)

Install using Composer.

```
{
    "require": {
        "benjaco/highway": "1.*"
    }
}
```

Usage
-----

[](#usage)

```
include "vendor/autoload.php";

use \benjaco\Highway\Highway;

// setup can be called if you dont want the default parameter, or Highway::$url can be set
// Highway::set_up(false);

Highway::get("/", function () {
    echo "index";
});

Highway::get("/testvar/{}", function ($var) {
    echo $var;
});

Highway::group("/user", function () {

    Highway::get("/{name}", function () {
        echo "Wellcome " . $_GET['name'];
    });

});

// its posible to define a regex the parameter must match, but the regex cant contain capture groups
Highway::addOption("danish_phone_number", "(?:\+45)?\d{8}");
Highway::get("/number/{phone:danish_phone_number}", function (){
    echo "Phone nr: " . $_GET['phone'];
});
// int is a standard one there can be used as well
Highway::get("/testint/{:int}", function ($var) {
    echo $var;
});

// optional parameter with default value
function using_function($id = "No parameter"){
    echo "Route using function ". $id;
}
Highway::get("/using_function", "using_function");
Highway::get("/using_function/{}", "using_function");

// using static functions in a class
// it will autoload the class only if its needed, if you are using a autoloader
Highway::get("/using_class", "UsingClass::Route");
Highway::get("/using_class/{}", "UsingClass::Route");

// using methods from a instance of a class
$classForRoutes = new UsingClass();
Highway::get("/using_class_init", [$classForRoutes, "AnotherRoute"] );
Highway::get("/using_class_init/{}", [$classForRoutes, "AnotherRoute"] );

Highway::not_found(function () {
    echo 404;
});
```

Collaboration
-------------

[](#collaboration)

All issues and pull requests are welcome

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.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 ~11 days

Total

2

Last Release

3275d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7045569?v=4)[Benjamin Schultz Larsen](/maintainers/benjaco)[@benjaco](https://github.com/benjaco)

---

Top Contributors

[![benjaco](https://avatars.githubusercontent.com/u/7045569?v=4)](https://github.com/benjaco "benjaco (22 commits)")[![benjaco-edu](https://avatars.githubusercontent.com/u/18687101?v=4)](https://github.com/benjaco-edu "benjaco-edu (2 commits)")

---

Tags

php-routerrouterrouting

### Embed Badge

![Health badge](/badges/benjaco-highway/health.svg)

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

###  Alternatives

[klein/klein

A lightning fast router for PHP

2.7k1.1M31](/packages/klein-klein)[pecee/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

675224.9k18](/packages/pecee-simple-router)[vlucas/bulletphp

A heierarchical resource-oriented micro-framework built on nested closures instead of route-based callbacks

41650.0k1](/packages/vlucas-bulletphp)[izniburak/router

simple router class for php

23323.2k7](/packages/izniburak-router)[vectorface/snappy-router

A quick and snappy routing framework.

4615.2k](/packages/vectorface-snappy-router)[thewunder/croute

Convention based routing for PHP

1319.4k](/packages/thewunder-croute)

PHPackages © 2026

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