rojtjo/laravel-auto-subscriber

laravel-auto-subscriber
6,806
Install
composer require rojtjo/laravel-auto-subscriber
Latest Version:0.4.0
PHP:^8.3
Laravel:12 · 13
Older releases:8 – 11
License:MIT
Last Updated:Mar 17, 2026
Links: GitHub  ·  Packagist
Maintainer: Rojtjo

laravel-auto-subscriber

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Automatically subscribe to all events for which your subscriber contains a handler. Under the hood we use reflection to detect all listeners defined on the subscriber.

Installation

You can install the package via composer:

composer require rojtjo/laravel-auto-subscriber

Usage

All you have to do is use the Rojtjo\LaravelAutoSubscriber\AutoSubscriber trait on your subscriber class. Also make sure to register your subscriber in the EventServiceProvider like you're used to.

Example

use Rojtjo\LaravelAutoSubscriber\AutoSubscriber;

final class UserNotifier
{
    use AutoSubscriber;

    public function welcomeUser(UserCreated $event): void
    {
        // Send welcome notification..
    }
}

This would equivalent to a handwritten subscriber like shown below.

use Illuminate\Contracts\Events\Dispatcher;

final class UserNotifier
{
    public function subscribe(Dispatcher $events)
    {
        $events->listen(UserCreated::class, [$this, 'welcomeUser']);
    }

    // ...
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

Related Packages

welderlourenco/laravel-seeder

Run your seeder files without touching your DatabaseSeeder.php file.

543 0
daneeveritt/login-notifications

Login notifications for Laravel

13,238 4
fish/eloquent-logger

Log Eloquent model changes to a designated logs table

13,980 8
shooka/laravel-modelevents

Let a service provider handle your model events

6,691 6

Version History

Version Released PHP Laravel License
0.4.0 ^8.3 ^12.0|^13.0 MIT
0.3.2 ^8.0 ^9.2.0|^10.0|^11.0|^12.0 MIT
0.3.1 ^8.0 ^9.2.0|^10.0|^11.0 MIT
0.3.0 ^8.0 ^9.2.0|^10.0|^11.0 MIT
0.2.1 ^7.4|^8.0 ^8.32|^9.2.|^10.00 MIT