PHPackages                             netmex/laravel-attributes - 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. [API Development](/categories/api)
4. /
5. netmex/laravel-attributes

ActiveLibrary[API Development](/categories/api)

netmex/laravel-attributes
=========================

A Laravel package to define routes using attributes.

1.0.0(2mo ago)00MITPHPPHP ^8.1

Since Mar 1Pushed 2mo agoCompare

[ Source](https://github.com/netmexmedia/Netmex-Laravel-Attributes-Route)[ Packagist](https://packagist.org/packages/netmex/laravel-attributes)[ RSS](/packages/netmex-laravel-attributes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Netmex - Laravel Attributes: Route
==================================

[](#netmex---laravel-attributes-route)

[![Packagist Version](https://camo.githubusercontent.com/a01172c8bd23ad9214ae637320b5a63ab8f3d26065bf6ff79bf47408e1b974bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65746d65782f6c61726176656c2d617474726962757465732e737667)](https://packagist.org/packages/netmex/laravel-attributes)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

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 `RouteMetadata` value object via a parser.
- Cache discovered metadata with optional automatic invalidation based on controller file mtimes.
- A `Registrar` service 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 &amp; Maintainer

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require netmex/laravel-attributes
```

The package supports Laravel's package auto-discovery. If you don't use auto-discovery, register the service provider in your application:

```
// config/app.php
'providers' => [
    // ...
    Netmex\Attributes\Route\AttributesRouteServiceProvider::class,
];
```

Quick Usage
-----------

[](#quick-usage)

Annotate controller classes and methods using the package attribute `Netmex\Laravel\Attributes\Route`.

Method-level example:

```
use Netmex\Laravel\Attributes\Route;

final class PostController
{
    #[Route(path: '/posts', name: 'posts.index', methods: ['GET'])]
    public function index()
    {
        // controller action
    }

    #[Route(path: '/posts/{id}', name: 'posts.show', methods: ['GET'], requirements: ['id' => '\\d+'])]
    public function show(int $id)
    {
        // controller action
    }
}
```

Class-level (group) example — apply a prefix and default middleware or naming:

```
use Netmex\Laravel\Attributes\Route;

#[Route(path: '/admin', name: 'admin.', middleware: ['auth'])]
final class Admin\DashboardController
{
    #[Route(path: '/dashboard', name: 'dashboard')]
    public function index() {}
}
```

Service Provider &amp; Services
-------------------------------

[](#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) into `RouteMetadata` instances.
- `Cache\RouteMetadataCache` — cache and return metadata arrays/objects.
- `Registrar\Registrar` and `Registrar\RouteRegistrar` — register routes into `Illuminate\Routing\Router` and apply model binding.

Configuration
-------------

[](#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
--------

[](#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):

```
php artisan attributes-route:clear
```

Contributing
------------

[](#contributing)

Contributions welcome. Suggested improvements and tests:

- Integration tests using `Orchestra\Testbench` to assert `Registrar::register()` registers routes into the router.
- Tests for the console cache-clear command and cache invalidation behavior.
- Add documentation examples showing `php artisan route:list` after registration.

License
-------

[](#license)

MIT License

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance92

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

69d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2df47b9a9f451d024ba0dcd7223464ea5fdb43f2be63765f4d26b15c41abd660?d=identicon)[Zany101](/maintainers/Zany101)

---

Top Contributors

[![Dvosensets](https://avatars.githubusercontent.com/u/212354996?v=4)](https://github.com/Dvosensets "Dvosensets (1 commits)")[![Zany101](https://avatars.githubusercontent.com/u/41392004?v=4)](https://github.com/Zany101 "Zany101 (1 commits)")

---

Tags

attributeattributeslaravellaravel-packagenetmexphpphp-attributephp-attributes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/netmex-laravel-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/netmex-laravel-attributes/health.svg)](https://phpackages.com/packages/netmex-laravel-attributes)
```

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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