PHPackages                             spiral-packages/event-bus - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. spiral-packages/event-bus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

spiral-packages/event-bus
=========================

A simple observer pattern implementation based on symfony event handler, allowing you to subscribe and listen for various events that occur within your application.

2.2.0(3y ago)62.9k2[1 PRs](https://github.com/spiral-packages/event-bus/pulls)MITPHPPHP ^8.1

Since Feb 11Pushed 3y ago2 watchersCompare

[ Source](https://github.com/spiral-packages/event-bus)[ Packagist](https://packagist.org/packages/spiral-packages/event-bus)[ Docs](https://github.com/spiral-packages/event-bus)[ RSS](/packages/spiral-packages-event-bus/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (5)Dependencies (10)Versions (8)Used By (0)

A simple observer pattern implementation based on symfony event handler (PSR-14 compatible)
===========================================================================================

[](#a-simple-observer-pattern-implementation-based-on-symfony-event-handler-psr-14-compatible)

[![PHP](https://camo.githubusercontent.com/19f9bcf99cdcae22304af40b60c38c6849b4df3cf57dd224be958010f17e2f76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73706972616c2d7061636b616765732f6576656e742d6275732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spiral-packages/event-bus)[![Latest Version on Packagist](https://camo.githubusercontent.com/28183a6264df8b27f556fb0712c806f9861c9bab4323f791b21e695615158276/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73706972616c2d7061636b616765732f6576656e742d6275732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spiral-packages/event-bus)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5a95a904949de53b5841c9aa72bf9c61f35eb1a1d18b9f1bc5b884b04e6fa78d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f73706972616c2d7061636b616765732f6576656e742d6275732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spiral-packages/event-bus/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1ef6464f3d4ec631e7aa04288267cd954bfecb7de7f509660ccb274055fef88e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73706972616c2d7061636b616765732f6576656e742d6275732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spiral-packages/event-bus)

Subscribe and listen for various events that occur within your application.

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

[](#requirements)

Make sure that your server is configured with following PHP version and extensions:

- PHP 8.0+
- Spiral framework 2.9+

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

[](#installation)

You can install the package via composer:

```
composer require spiral-packages/event-bus
```

After package install you need to register bootloader from the package.

```
protected const LOAD = [
    // ...
    \Spiral\EventBus\Bootloader\EventBusBootloader::class,
];
```

or

```
namespace App\Bootloader;

use Spiral\EventBus\Bootloader\EventBusBootloader as BaseBootloader

class EventBusBootloader extends BaseBootloader
{
    protected const LISTENS = [
        \App\Event\UserCreated::class => [
            \App\Listener\SendWelcomeMessageListener::class
        ],
        //...
    ];
}
```

Usage
-----

[](#usage)

At first need create config file `app/config/event-bus.php`, where you can specify listeners.

```
