PHPackages                             codehouse/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. [API Development](/categories/api)
4. /
5. codehouse/highway

AbandonedArchivedLibrary[API Development](/categories/api)

codehouse/highway
=================

A regular expression based router with spring-stype configuration (with DI support)

1.0(9y ago)020GPLv3PHP

Since Jul 27Pushed 8y agoCompare

[ Source](https://github.com/Shmarkus/highway)[ Packagist](https://packagist.org/packages/codehouse/highway)[ RSS](/packages/codehouse-highway/feed)WikiDiscussions master Synced 4w ago

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

\#Highway The library is a wrapper over [mrjgreen/phroute](https://github.com/mrjgreen/phroute) routing library. The added functionality is following:

- Annotation based configuration for controllers (**@Controller**)
- Annotation based configuration for request mapping (**@RequestMapping**)
- Annotation based configuration for protected content (**@Security**)
- Dependency injection support

Initialization
--------------

[](#initialization)

### Basic

[](#basic)

To get the system working, put the following to your index.php (assuming that your controllers are in /src/Controller folder and in Controller namespace):

```
$router = new CodeHouse\Highway\Router(__DIR__ . '/src/Controller', 'Controller');
echo $router->serve($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
```

### Dependency injection

[](#dependency-injection)

In order to use dependency injection, after initializing the router, initialize DI container and pass it to the Highway instance:

```
$builder = new \DI\ContainerBuilder();
$builder->useAnnotations(true);
$router->setDiContainer($builder->build());
```

### Security

[](#security)

If you need to use role based authorization, you must pass security handler to Highway router instance. The security handler defines methods that are invoked when router finds @Security annotation. An example security handler looks something like this:

```
class SecurityHandler
{
    public static function admin()
    {
        $auth = new \Services\Authentication();
        if ($auth->getLoggedInUserRole() != UserRoles::ADMIN) {
            throw new InvalidRoleException('Role needed: ' . UserRoles::ADMIN . ', Role found: ' . $auth->getLoggedInUserRole());
        }
    }
}
```

It checks whether user has the admin role and if not, then throws an InvalidRoleException! This method is invoked when user is trying to access a method that is annotated with @Security annotation and the annotation has role value "admin".

Configuring the router to use the handler is simple:

```
$router = new CodeHouse\Highway\Router(__DIR__ . '/src/Controller', 'Controller', new SecurityHandler());
echo $router->serve($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
```

Annotations
-----------

[](#annotations)

### Controller

[](#controller)

This annotation is indicative for the library. All other annotations are scanned only if the class is annotated with the @Controller annotation!

```
use \CodeHouse\Highway\Annotations as Highway;

/**
 * @Highway\Controller
 */
 class SomeController { .. }

```

### Request mapping

[](#request-mapping)

This annotation is used on methods to indicate the URL that will point to this current method. Note that you can only use each URL and method once.

```
use \CodeHouse\Highway\Annotations as Highway;

...

/**
 * @Highway\RequestMapping(value="/users", method="get")
 */
 public function listUsers() { ... }

...

```

Note that the method name does not matter here. When user navigates to \[server\]/users then the return value of *listUsers()* is served!

You can also use dynamic URLs. Read about them from mrjgreen's page!

### Security

[](#security-1)

If you have to restrict access to certain methods, then use the @Security tag.

```
use \CodeHouse\Highway\Annotations as Highway;

...

/**
 * @Highway\Security(role="admin")
 */
 public function adminOnlyMethod() { ... }

...

```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

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

Unknown

Total

1

Last Release

3626d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6381245?v=4)[Markus Karileet](/maintainers/shmarkus)[@Shmarkus](https://github.com/Shmarkus)

---

Top Contributors

[![Shmarkus](https://avatars.githubusercontent.com/u/6381245?v=4)](https://github.com/Shmarkus "Shmarkus (2 commits)")

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M724](/packages/sylius-sylius)[api-platform/doctrine-common

Common files used by api-platform/doctrine-orm and api-platform/doctrine-odm

274.4M48](/packages/api-platform-doctrine-common)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k12](/packages/2lenet-crudit-bundle)[neos/media

The Media package

101.2M53](/packages/neos-media)[concrete5/core

Concrete core subtree split

20166.1k49](/packages/concrete5-core)[ddeboer/salesforce-mapper-bundle

A Salesforce API mapper

2835.3k](/packages/ddeboer-salesforce-mapper-bundle)

PHPackages © 2026

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