Download the PHP package horizom/routing without Composer
On this page you can find all versions of the php package horizom/routing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package routing
Horizom Routing
Lightweight PSR-friendly routing for Horizom applications, built on top of FastRoute.
The package provides:
- HTTP route registration for all common verbs
- Group prefixes, middleware and attributes
- Resource-style route generation
- Redirect and permanent redirect helpers
- PSR-11 container based handler resolution
- Lazy handler resolution for lower bootstrap cost
- PSR-15 compatible request dispatching
Requirements
- PHP 8.0+
- A PSR-11 container
Installation
Quick Start
Use RouterFactory when you want eager handler resolution, or RouterLazyFactory when handlers should be resolved only when a route is matched.
Registering Routes
The router supports the usual HTTP verbs plus map() and any().
Supported handler styles:
Controller::class . '@method'InvokableController::class[Controller::class, 'method']- Closures returning a
Psr\Http\Message\ResponseInterface
Route Groups
Groups let you share a common prefix and route metadata.
Group metadata is applied to every route created inside the callback.
Resource Routes
resource() generates the conventional CRUD endpoints for a controller.
Generated route names:
posts.indexposts.createposts.storeposts.showposts.editposts.updateposts.destroy
You can limit the generated endpoints with only or except.
To register multiple resources at once:
Redirects
Factories
RouterFactory
RouterFactory builds a router with eager handler resolution.
RouterLazyFactory
RouterLazyFactory defers handler resolution until route compilation/matching.
Error Handling
RouterHandler throws typed exceptions for common routing failures:
Horizom\Routing\Exceptions\NotFoundExceptionwith code404Horizom\Routing\Exceptions\MethodNotAllowedExceptionwith code405
MethodNotAllowedException::getAllowedMethods() returns the HTTP methods accepted by the matched route.
Testing And Validation
Run the package checks with:
The test suite covers route registration, resource filtering, group metadata, redirects, factories, lazy resolution, invocation, dispatching and exception behavior.
Notes
- Route handlers must declare a non-null
ResponseInterfacereturn type. - Route definitions become immutable once compiled.
- Middleware entries must be strings or
Psr\Http\Server\MiddlewareInterfaceimplementations.
License
MIT. See LICENSE.md.
All versions of routing with dependencies
horizom/dispatcher Version ^5.2
nikic/fast-route Version ^1.3
nyholm/psr7 Version ^1.5
php-di/invoker Version ^2.3
psr/container Version ^1.0
psr/http-message Version ^1.0
psr/http-server-handler Version ^1.0