PHPackages                             fhooe/router-skeleton - 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. fhooe/router-skeleton

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

fhooe/router-skeleton
=====================

An example application or skeleton for getting started with fhooe/router.

v3.0.0(1mo ago)0235[1 issues](https://github.com/Digital-Media/fhooe-router-skeleton/issues)MITLattePHP ^8.5

Since Dec 16Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Digital-Media/fhooe-router-skeleton)[ Packagist](https://packagist.org/packages/fhooe/router-skeleton)[ RSS](/packages/fhooe-router-skeleton/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (13)Versions (10)Used By (0)

[![The fhooe/router-skeleton Logo: Three containers arrows going in different directions: left, up, and right.](https://raw.githubusercontent.com/Digital-Media/fhooe-router-skeleton/076902786d9e13145b315154b0ea30b6222e3055/views/images/fhooe-router-logo.svg)](https://raw.githubusercontent.com/Digital-Media/fhooe-router-skeleton/076902786d9e13145b315154b0ea30b6222e3055/views/images/fhooe-router-logo.svg) fhooe/router-skeleton
============================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-fhooerouter-skeleton)

An example application, a.k.a. skeleton for getting started with [*fhooe/router*](https://github.com/Digital-Media/fhooe-router): the simple object-oriented router developed for PHP classes in the [Media Technology and Design](https://fh-ooe.at/en/degree-programs/media-technology-and-design-bachelor) program at the [University of Applied Sciences Upper Austria](https://fh-ooe.at/en/campus-hagenberg). This skeleton and the library behind it are primarily designed for educational purposes (learning the concept of routing and object-oriented principles). Use it for "public" applications at your own risk.

Creating a *fhooe/router* Application
-------------------------------------

[](#creating-a-fhooerouter-application)

Use Composer to create a new project containing the skeleton files:

```
composer create-project fhooe/fhooe-router-skeleton path/to/install
```

Composer will create a project in the specified `path/to/install` directory.

Basic Usage
-----------

[](#basic-usage)

The router invocation happens in `public/index.php`. This front controller file receives all the requests since the associated `.htaccess` file will redirect everything to it.

*fhooe/router* can be used in two ways:

### Using a `Router` Object (recommended)

[](#using-a-router-object-recommended)

1. Instantiate the `Router` class.

    ```
    $router = new Router();
    ```

    **Adding a logger:** Pass an instance of a PSR-3 compatible logger application, e.g., [Monolog](https://packagist.org/packages/monolog/monolog), to receive predefined log messages about routes being added and executed. This can be useful to track what the Router is doing.

    ```
    $logger = new Logger("skeleton-logger");
    // add processors, formatters or handlers to the logger
    $router = new Router($logger);
    ```
2. Define routes using the `get()` and `post()` methods. Supply a URI pattern to match against and a callback that is executed when the pattern and HTTP method match.

    ```
    $router->get("/", function () {
        // e.g., load a view
    });
    ```

    **Placeholders:** You can define route placeholders using curly brackets. The name of the placeholder will be available as a parameter in the callback, and the actual value in the URI will be its argument.

    ```
    $router->get("/product/{id}", function ($id) {
       // e.g., load a view to display the product
    });
    ```

    **Optional parts:** You can make route parts optional by putting them in square brackets. That way, a route will match both ways. This can be, for example, used to make a route work with or without a trailing slash.

    ```
    $router->get("/form[/]", function () {
       // e.g., load a view
    });
    ```
3. Set a 404 callback to load a view or trigger behavior when no route matches.

    ```
    $router->set404Callback(function () {
        // e.g., load a 404 view
    });
    ```
4. Optional: Define a base path if your application is not located in your server's document root.

    ```
    $router->basePath = "/path/to/your/files";
    ```
5. Run the router. This will fetch the current URI, match it against the defined routes, and execute them if a match is found.

    ```
    $router->run();
    ```

### Using the Static Routing Method `Router::getRoute()`

[](#using-the-static-routing-method-routergetroute)

1. Invoke the static method. Provide a base path as an argument if your project is not located in your server's document root. The method returns the route as a string in the form of `METHOD /pattern` , e.g., `GET /`, when a GET request was made to the root directory.

    ```
    $route = Router::getRoute("/path/to/your/files");
    ```
2. Use a conditional expression to decide what to do with the matched route.

    ```
    switch($route) {
        case "GET /":
            // e.g., load a view
            break;
        default:
            // e.g., load the 404 view
            break;
    }
    ```

Displaying Output
-----------------

[](#displaying-output)

Simple example view files in the form of HTML and PHP files are located in the `views` directory together with [Twig](https://packagist.org/packages/twig/twig) examples for cleaner output.

Three Twig extensions have been added.

- `RouterExtension` provides the functions `url_for()` and `get_base_path()` in templates for generating URLs and retrieving the base path from the `Router` object.
- `SessionExtension` provides the function `session(key)` for retrieving entries in the `$_SESSION` superglobal.
- `DebugExtension` provides the function `dump()` for dumping variables in templates (similar to `var_dump()`).

Browsing the Application
------------------------

[](#browsing-the-application)

To take a quick look, you can use the PHP built-in web server:

```
cd path/to/install
composer start

```

Navigate to  in your browser to see the application in action.

Contributing
------------

[](#contributing)

If you'd like to contribute, please refer to [CONTRIBUTING](https://github.com/Digital-Media/fhooe-router-skeleton/blob/main/CONTRIBUTING.md) for details.

License
-------

[](#license)

*fhooe/router-skeleton* is licensed under the MIT license. See [LICENSE](https://github.com/Digital-Media/fhooe-router-skeleton/blob/main/LICENSE) for more information.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance90

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 96.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 ~195 days

Total

9

Last Release

47d ago

Major Versions

v0.3.1 → v1.0.02024-02-05

v1.0.1 → v2.0.02025-03-26

v2.0.0 → v3.0.0.x-dev2026-02-22

PHP version history (4 changes)v0.1.0PHP &gt;=7.4

v1.0.0PHP ^8.3

v2.0.0PHP ^8.4

v3.0.0.x-devPHP ^8.5

### Community

Maintainers

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

---

Top Contributors

[![hochleitner](https://avatars.githubusercontent.com/u/2236807?v=4)](https://github.com/hochleitner "hochleitner (117 commits)")[![martinharrer](https://avatars.githubusercontent.com/u/18611980?v=4)](https://github.com/martinharrer "martinharrer (4 commits)")

---

Tags

routingexampleeducation

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[lord/laroute

Access Laravels URL/Route helper functions, from JavaScript.

8022.0M8](/packages/lord-laroute)[bramus/router

A lightweight and simple object oriented PHP Router

1.1k458.8k49](/packages/bramus-router)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[illuminatech/url-trailing-slash

Allows enforcing URL routes with or without trailing slash

50216.9k](/packages/illuminatech-url-trailing-slash)

PHPackages © 2026

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