Download the PHP package jerowork/route-attribute-provider without Composer
On this page you can find all versions of the php package jerowork/route-attribute-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jerowork/route-attribute-provider
More information about jerowork/route-attribute-provider
Files in jerowork/route-attribute-provider
Package route-attribute-provider
Short Description Define routes by PHP8 attributes
License MIT
Informations about the package route-attribute-provider
route-attribute-provider
Define routes by PHP8 attributes.
Installation
Install via Composer:
Configuration
In order to use route attributes, pick any of the existing framework implementations or create a custom one.
Instantiate RouteAttributeConfigurator
somewhere close to the construction of your application,
e.g. in your front controller (or ideally register in your PSR-11 container).
Basic configuration:
Extended configuration:
Existing implementations
- jerowork/slim-route-attribute-provider for Slim
- brenoroosevelt/league-route-attribute-provider for League/Route
Or check packagist for any other implementations.
Custom implementation
Create a custom implementation by using RouteAttributeProviderInterface
.
A (fictive) custom implementation:
Cache
By default, caching of route attributes is disabled. This is fine for a development environment.
However, for a production environment you should use a more efficient way of route attribute loading. Therefore you can use any PSR-16 cache implementation.
Note: Any PSR-6 cache implementation can be used too, by using Symfony's PSR-6 to PSR-16 adapter.
Usage
A route can be defined via PHP8 attributes.
Minimalist example:
Extended example:
Full-fledged example:
All versions of route-attribute-provider with dependencies
jerowork/file-class-reflector Version ^0.3
psr/simple-cache Version ^1.0 || ^2.0 || ^3.0