Download the PHP package netmex/laravel-attributes without Composer
On this page you can find all versions of the php package netmex/laravel-attributes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download netmex/laravel-attributes
More information about netmex/laravel-attributes
Files in netmex/laravel-attributes
Package laravel-attributes
Short Description A Laravel package to define routes using attributes.
License MIT
Informations about the package laravel-attributes
Netmex - Laravel Attributes: Route
Lightweight Laravel package to define and register HTTP routes using PHP Attributes on controllers and methods.
Key features
- Define routes declaratively with a
#[Route(...)]PHP Attribute on controllers and methods. - Convert attributes into a compact
RouteMetadatavalue object via a parser. - Cache discovered metadata with optional automatic invalidation based on controller file mtimes.
- A
Registrarservice that wires metadata into the Laravel router (route registration and model binding helpers).
Table of Contents
- Installation
- Quick Usage
- Class-level group attributes
- Service Provider
- Configuration
- Commands
- Contributing
- License & Maintainer
Installation
Install the package via Composer:
The package supports Laravel's package auto-discovery. If you don't use auto-discovery, register the service provider in your application:
Quick Usage
Annotate controller classes and methods using the package attribute Netmex\Laravel\Attributes\Route.
Method-level example:
Class-level (group) example — apply a prefix and default middleware or naming:
Service Provider & Services
The package registers the following services in the container via AttributesRouteServiceProvider:
Discovery\ControllerDiscovery— discover controller classes from the configured path/namespace.Parser\AttributeParser— parse attributes (Reflection) intoRouteMetadatainstances.Cache\RouteMetadataCache— cache and return metadata arrays/objects.Registrar\RegistrarandRegistrar\RouteRegistrar— register routes intoIlluminate\Routing\Routerand apply model binding.
Configuration
Publish or review config/attributes-route.php for the following options:
cache_key(string) — cache key prefix (default:attributes_route_metadata).cache_ttl(int|null) — TTL in seconds (null = forever).auto_invalidate(bool) — append a mtime-based hash to the cache key so metadata is automatically invalidated when controller files change.
Commands
The package includes a console command to clear the metadata cache. You can call it via artisan (command name is provided by the package service provider):
Contributing
Contributions welcome. Suggested improvements and tests:
- Integration tests using
Orchestra\Testbenchto assertRegistrar::register()registers routes into the router. - Tests for the console cache-clear command and cache invalidation behavior.
- Add documentation examples showing
php artisan route:listafter registration.
License
MIT License