PHPackages                             aidynmakhataev/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. aidynmakhataev/laravel-attributes

ActiveLibrary

aidynmakhataev/laravel-attributes
=================================

Auto register laravel event listeners, command handlers and routes using PHP attributes

1.0.1(4y ago)111MITPHPPHP ^8.0

Since Feb 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/AidynMakhataev/laravel-attributes)[ Packagist](https://packagist.org/packages/aidynmakhataev/laravel-attributes)[ RSS](/packages/aidynmakhataev-laravel-attributes/feed)WikiDiscussions main Synced 4d ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

Laravel Attributes
==================

[](#laravel-attributes)

This package provides php attributes automatically register Laravel routes, event listeners and command bus handlers.

Requirements
------------

[](#requirements)

- PHP ^8.0
- Laravel ^8.0

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

[](#installation)

You can install the package via composer:

```
composer require aidynmakhataev/laravel-attributes
```

You can publish the config file with:

```
php artisan vendor:publish --provider="AidynMakhataev\LaravelAttributes\LaravelAttributesServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [
    'events' => [
        /*
         * Automatic registration of listeners will only happen if this setting is `true`
         */
        'enabled'       => true,

        /*
         * Listeners in these directories that have attributes will automatically be registered.
         */
        'directories'   => [
            base_path('app/Listeners')
        ]
    ],

    'command_bus' => [
        /*
         * Automatic registration of command handlers will only happen if this setting is `true`
         */
        'enabled'       => true,

        /*
         * Handlers in these directories that have attributes will automatically be registered.
         */
        'directories'   => [
            base_path('app/CommandHandlers')
        ],
    ],

    'routing' => [
        /*
         * Automatic registration of routes will only happen if this setting is `true`
         */
        'enabled'       => true,

        /*
         * Controllers in these directories that have attributes will automatically be registered.
         */
        'directories'   => [
            base_path('app/Http/Controllers')
        ],
    ],
];
```

Usage
=====

[](#usage)

The package provides several annotations that should be put on your methods.

Event Listeners
---------------

[](#event-listeners)

```
namespace App\Listeners;

use AidynMakhataev\LaravelAttributes\Attributes\EventListener;
use App\Events\OrderShipped;

class SendShipmentNotification
{
    #[EventListener]
    public function handle(OrderShipped $event)
    {
        //
    }
}
```

This attribute will automatically register this listener by executing following command:

```
Event::listen(OrderShipped::class, 'SendShipmentNotification@handle');
```

Command Handlers
----------------

[](#command-handlers)

```
namespace App\CommandHandlers;

use AidynMakhataev\LaravelAttributes\Attributes\CommandHandler;
use App\Events\OrderShipped;

class CreateOrderCommandHandler
{
    #[CommandHandler]
    public function handle(CreateOrderCommand $command)
    {
        //
    }
}
```

This attribute will automatically register this handler by executing following command:

```
Bus::map([
    CreateOrderCommand::class => CreateOrderCommandHandler::class,
]);
```

Routing
-------

[](#routing)

```
namespace App\Http\Controllers;

use AidynMakhataev\LaravelAttributes\Attributes\Route;
use App\Events\OrderShipped;
use Illuminate\Http\Request;

class OrderController
{
    #[Route(path: '/orders', methods: ['POST'], name: 'orders.store', middlewares: ['auth'])]
    public function store(Request $request)
    {
        //
    }
}
```

This attribute will automatically register this route by executing following command:

```
Route::post('/orders', [OrderController::class, 'store'])->name('orders.store')->middlewares(['auth']);
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~93 days

Total

3

Last Release

1713d ago

Major Versions

0.1.0 → 1.0.02021-09-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/05bd73f86bccc02a979273fd6b74f2573e3f3c1d2120a879a15c74d8d6abbf63?d=identicon)[AidynMakhataev](/maintainers/AidynMakhataev)

---

Top Contributors

[![AidynMakhataev](https://avatars.githubusercontent.com/u/19181566?v=4)](https://github.com/AidynMakhataev "AidynMakhataev (3 commits)")

---

Tags

laravel-attributesaidynmakhataevlaravel listener attributeslaravelattributes

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[studio/laravel-totem

A Laravel package to manage your cron jobs through a beautiful dashboard

1.8k1.1M](/packages/studio-laravel-totem)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[sassnowski/venture

A package to manage complex workflows built on top of Laravel's queue.

825254.5k1](/packages/sassnowski-venture)[flat3/lodata

OData v4.01 Producer for Laravel

96320.9k](/packages/flat3-lodata)

PHPackages © 2026

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