oihana/php-routes

The Oihana PHP Routes library

Maintainers

Package info

github.com/BcommeBois/oihana-php-routes

pkg:composer/oihana/php-routes

Statistics

Installs: 8

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-06-21 15:28 UTC

This package is auto-updated.

Last update: 2026-06-21 15:29:55 UTC


README

Oihana PHP Routes

Declarative, composable HTTP route definitions for PHP 8.4+, built on Slim.

Latest Version
Total Downloads
License

📚 Documentation

User guides (FR + EN), with narrative explanations and examples:

🇬🇧 English documentation 🇫🇷 Documentation française
Getting started, routes, HTTP method routes, document & i18n routes, helpers, testing. Démarrage, routes, routes par méthode HTTP, routes document & i18n, helpers, tests.

Auto-generated API reference (phpDocumentor):
👉 https://bcommebois.github.io/oihana-php-routes

🧠 What is it?

oihana/php-routes provides a small, declarative layer for defining HTTP routes on top of Slim: a composable Route base, one class per HTTP verb (GetRoute, PostRoute, …), higher-level DocumentRoute / I18nRoute, and helpers to register them on a Slim app from a PSR-11 container. Each route maps a URL pattern to a controller method.

use DI\Container;
use Slim\Factory\AppFactory;
use Slim\App;

use oihana\routes\http\GetRoute;

$container = new Container();
AppFactory::setContainer( $container );
$app = AppFactory::create();
$container->set( App::class , $app );

// Register: GET /api/test  ->  $controller->get()
$route = new GetRoute( $container , [
    'controllerID' => 'my.controller',
    'route'        => 'api/test',
] );

$route(); // registers the route on the Slim app

For full details (route classes, flags, helpers), see the table of contents in the documentation.

🚀 Features

  • 🧭 A composable Route base and per-verb route classes — GetRoute, PostRoute, PutRoute, PatchRoute, DeleteRoute, DeleteAllRoute, OptionsRoute, ListRoute.
  • 📄 Higher-level routes — DocumentRoute and I18nRoute for documents and localized paths.
  • 🚩 Declarative route options via the RouteFlag bit flags.
  • 🧩 Route registration helpers — HttpMethodRoutesTrait, HasRouteTrait, plus withPlaceholder() and responsePassthrough().
  • 🔗 Built on Slim and wired through a PSR-11 container.
  • 🧪 Full unit-test coverage ensuring reliability and maintainability.

💡 Designed to be composable, testable, and compatible with any PHP 8.4+ project.

📦 Installation

Requires PHP 8.4+

Install via Composer:

composer require oihana/php-routes

oihana/php-routes depends on oihana/php-controllers, which requires the ext-imagick extension — make sure it is installed.

✅ Tests & coverage

Run the full unit-test suite (PHPUnit, strict mode):

composer test

Run a single test case:

./vendor/bin/phpunit --filter GetRouteTest

Measure coverage (requires Xdebug or PCOV):

composer coverage        # text + Clover + HTML under build/coverage/
composer coverage:md     # readable Markdown summary (build/coverage/COVERAGE.md)

The suite runs in strict mode and targets 100% line coverage.

🧾 License

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).

👤 About the author

🛠️ Generate the Documentation

We use phpDocumentor to generate the documentation into the ./docs folder.

Usage

Run the command :

composer doc

🔗 Related packages