PHPackages                             rsthn/rose-ext-router - 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. rsthn/rose-ext-router

ActiveRose-extension[Utility &amp; Helpers](/categories/utility)

rsthn/rose-ext-router
=====================

Router Extension (Rose)

1.0.13(4y ago)11201Apache-2.0PHP

Since Sep 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/rsthn/rose-ext-router)[ Packagist](https://packagist.org/packages/rsthn/rose-ext-router)[ RSS](/packages/rsthn-rose-ext-router/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (14)Used By (1)

Router Extension
================

[](#router-extension)

This extension adds content routing features to [Rose](https://github.com/rsthn/rose-core).

```
composer require rsthn/rose-ext-router
```

After installation ensure Router is the primary service in your system by editing the `Gateway` section of your `system.conf` file and set `service=router`. Additionally unless you want to use `index.php/my-route/` we recommend you enable URL rewriting to make pretty URLs. If using Apache or compatible an `.htaccess` like the following will do:

```
RewriteEngine On
RewriteBase /my-project/

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

```

Default Operation
=================

[](#default-operation)

Router will use the relative path provided by `Gateway` (i.e. when using something like `index.php/home` the relative path is `/home`) and return the appropriate content using the following rules (in order of precedence, whichever is satisfied first):

- User is authenticated1 and there is a `rcore/content/home/private.html` file, it will be loaded, evaluated with `Expr` and sent to the client.
- User is not authenticated and there is a `rcore/content/home/public.html` file, it will be loaded, evaluated with `Expr` and sent to the client.
- When a `rcore/content/home/index.html` file exists, it will be loaded, evaluated with `Expr` and sent to the client.
- User is not authenticated and there is only a `rcore/content/home/private.html` then Router will redirect to `/login`.
- Router will redirect to `/404`.

1The condition "authenticated user" is determined by checking if the `user` field of the current session (if any) is set to a non-null value (as set by [Sentinel](https://github.com/rsthn/rose-core)).

Routing to Services or URLs
===========================

[](#routing-to-services-or-urls)

When a certain route (i.e. `/api`) should pass control to another Rose service (i.e. `wind`) or redirect to a URL you can use the `Router` section of the `system.conf` file to achieve this, by providing "route=service\_name" pairs (where route is a delimiter-less regex), such as:

```
[Router]
/api = service:wind
/details/([0-9]+) = service:wind/?f=get-details&id=(1)
/external-page = location:https://example.com/contact-us/
/([0-9]+)/home = home/(1)
```

Service Redirection
-------------------

[](#service-redirection)

- Using the `service:` prefix in the value will cause an internal redirection to the specified service.

    - i.e. `/api = service:wind` will redirect to service `wind`.
- Any path provided in the value will be set as the new relative path.

    - i.e. `/api = service:wind/details` will redirect to service `wind` setting relative path to `/details`.
- Any path provided by the client after the route base will be appended to the relative path.

    - i.e. `/api = service:wind/details` but loaded from client as `/api/users` will cause redirection to service `wind` with relative path `/details/users`.
- Any query parameters in the value will be merged into the current request parameters.

    - i.e. `/api = service:wind/details?b=B` and loaded from client as `/api/users?a=A` will cause redirection to service `wind` with relative path `/details/users` and request parameters `a=A&b=B`.

Location Redirection
--------------------

[](#location-redirection)

- Using the `location:` prefix in the value will cause the `location` header to be set in the response HTTP headers and an immediate execution termination.

    - i.e. `/contact = location:https://example.com/` will redirect to URL `https://example.com/`.
- Any path provided by the client after the route base will be ignored.

    - i.e. `/contact = location:https://example.com/` and loaded from client as `/contact/sub-path/` will redirect to `https://example.com/`.
- Any query parameters specified by the client will be ignored.

    - i.e. `/contact = location:https://example.com/?a=A` and loaded from client as `/contact/sub-path/?b=B` will redirect to `https://example.com/?a=A`.

Notes
-----

[](#notes)

The value of routes is evaluated using `Expr`, therefore any formating can be made if needed, and variables from the gateway's request parameter map can be accessed as usual via `(gateway.request.)`.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

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

Every ~48 days

Recently: every ~36 days

Total

13

Last Release

1489d ago

### Community

Maintainers

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

---

Top Contributors

[![strikeone88](https://avatars.githubusercontent.com/u/50781762?v=4)](https://github.com/strikeone88 "strikeone88 (14 commits)")

### Embed Badge

![Health badge](/badges/rsthn-rose-ext-router/health.svg)

```
[![Health](https://phpackages.com/badges/rsthn-rose-ext-router/health.svg)](https://phpackages.com/packages/rsthn-rose-ext-router)
```

PHPackages © 2026

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