PHPackages                             attr-route/laravel-attribute-route - 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. [Framework](/categories/framework)
4. /
5. attr-route/laravel-attribute-route

ActiveLibrary[Framework](/categories/framework)

attr-route/laravel-attribute-route
==================================

Enterprise-grade Laravel routing via PHP Attributes

v1.1.0(3mo ago)00MITPHPPHP ^8.1

Since Mar 6Pushed 3mo agoCompare

[ Source](https://github.com/SulmaneDev/laravel-attribute-route)[ Packagist](https://packagist.org/packages/attr-route/laravel-attribute-route)[ RSS](/packages/attr-route-laravel-attribute-route/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel Attribute Routing
=========================

[](#laravel-attribute-routing)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6c09c93f919042283a5ecfca623b060b50268eeddf091bbd94e95961634570d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617474722d726f7574652f6c61726176656c2d6174747269627574652d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/attr-route/laravel-attribute-route)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1e4f52d6064a8d3ebcb0ae524086c65390f4ab2b8ea0574716a1f4e7c7ce58ac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f617474722d726f7574652f6c61726176656c2d6174747269627574652d726f7574652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/attr-route/laravel-attribute-route/actions)[![Total Downloads](https://camo.githubusercontent.com/6e48ac136bcdfd56216a0c80e6ba6622ef9f384bf9fe3b5e1c3f9a84a1f44f0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617474722d726f7574652f6c61726176656c2d6174747269627574652d726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/attr-route/laravel-attribute-route)

Created with love and with other contributors.

**Laravel Attribute Routing** is an enterprise-grade package that revolutionizes how you define routes in Laravel. Using PHP 8 Attributes, you can keep your routing logic close to your controllers, maintaining military-grade security and optimized performance.

🚀 Key Features
--------------

[](#-key-features)

- **Intuitive Attributes**: Define routes directly as "decorators" on your controller methods.
- **Controller-Level Groups**: Define shared prefixes, middleware, and names at the class level.
- **Advanced Throttling**: Support for tiered, repeatable `#[RateLimit]` attributes.
- **Unified Validation**: Inline `#[Validate]` attribute for automated request validation.
- **Role/Policy Security**: Seamless integration with Laravel Gates and Policies via `#[Authorize]`.
- **High Performance**: Optimized `RouteTree` matching and production-ready `RouteCache`.
- **Military-Grade Security**: Namespace whitelisting and path injection prevention out of the box.

📦 Installation
--------------

[](#-installation)

Install the package via composer:

```
composer require attr-route/laravel-attribute-route
```

Publish the config file:

```
php artisan vendor:publish --provider="AttrRoute\AttributeRoute\AttributeRouteServiceProvider" --tag="config"
```

### Smart Route Inference

[](#smart-route-inference)

The package automatically infers missing route properties from your controller methods, reducing boilerplate:

```
#[Route(method: 'GET')]
public function showProfile() { ... }
// Result: URI = /show-profile, Name = show-profile
```

- **Paths**: CamelCase methods are automatically converted to kebab-case URIs.
- **Names**: Route names are inferred from the method name if not explicitly provided.

### Attribute "Decorators"

[](#attribute-decorators)

Using the built-in `RouteAttributeMiddleware`, attributes like `#[Validate]` and `#[Authorize]` behave like decorators, executing logic before your controller method:

```
#[Route(method: 'POST', path: '/users')]
#[Validate(rules: ['email' => 'required|email'])]
public function store(Request $request) { ... }
```

🧪 Enterprise Testing
--------------------

[](#-enterprise-testing)

The package includes a comprehensive suite of tests:

- **Unit Tests**: Isolated testing for core services.
- **Feature Tests**: Full integration testing via Orchestra Testbench.

Run tests using PHPUnit:

```
vendor/bin/phpunit
```

⚙️ Configuration
----------------

[](#️-configuration)

The `config/route-attributes.php` file allows you to customize:

- `scan_paths`: Which directories should be scanned for attributes.
- `allowed_namespaces`: Whitelist of namespaces for secure discovery.
- `cache`: Enable/disable production route caching.

🛡️ Security
-----------

[](#️-security)

This package enforces strict security policies by default:

- **Namespace Whitelisting**: Only controllers in allowed namespaces are scanned.
- **Injection Blocking**: Route paths are validated against malicious character patterns.
- **State-Change Protection**: Automated checks for state-changing HTTP methods.

🚀 Performance
-------------

[](#-performance)

- **Lazy Loading**: Attributes are parsed via Reflection without instantiating controllers.
- **Optimized Matching**: Uses a segment-based tree for fast route lookups.
- **Route Caching**: Supports serialized route maps for zero-latency production boots.

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance79

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

113d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79234c49decde7f5c2a4bcd3e5455e4d20aa65be72e4cce43de7cba2f3441e97?d=identicon)[SulmaneDev](/maintainers/SulmaneDev)

---

Top Contributors

[![SulmaneDev](https://avatars.githubusercontent.com/u/185767242?v=4)](https://github.com/SulmaneDev "SulmaneDev (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/attr-route-laravel-attribute-route/health.svg)

```
[![Health](https://phpackages.com/badges/attr-route-laravel-attribute-route/health.svg)](https://phpackages.com/packages/attr-route-laravel-attribute-route)
```

###  Alternatives

[livewire/livewire

A front-end framework for Laravel.

23.5k84.3M2.5k](/packages/livewire-livewire)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M120](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.5k17.6M515](/packages/laravel-boost)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k28.4M137](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M122](/packages/laravel-pulse)

PHPackages © 2026

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