PHPackages                             hasan-22/event-listener - 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. hasan-22/event-listener

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

hasan-22/event-listener
=======================

With this package, you can easily add and use event and listener to your project

v1.0.0(3y ago)012MITPHP

Since Feb 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/HASSAN-22/event-listener)[ Packagist](https://packagist.org/packages/hasan-22/event-listener)[ Docs](https://github.com/HASSAN-22/event-listener)[ RSS](/packages/hasan-22-event-listener/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP event listener
------------------

[](#php-event-listener)

#### With this package, you can easily add and use `event` and `listener` to your project

[](#with-this-package-you-can-easily-add-and-use-event-and-listener-to-your-project)

---

```
   composer require hasan-22/event-listener

```

---

Usage:

You can create a class for the event and a class for the listener. Note that the Listener class must be implemented from the `\EventListener\ListenerInterface` interface

In this example, we think we have two event listener classes for login

Our classes name is `LoginEvent` and `LoginListener`

```
require_once __DIR__.'/vendor/autoload.php';

//With function listen we can add register our event and listener
\EventListener\Event::listen(LoginEvent::class, LoginListener::class);

// Now we can fire events anywhere in the project like this
\EventListener\Event::fire(new LoginEvent());

// If your event have constructor with parameters you can pass the parameters like this
// Be careful that your parameters must have public access
\EventListener\Event::fire(new LoginEvent('Armia','123456'));
```

---

If you don't want to create class for listener and event, we can create event and listener in this way

```
\EventListener\Event::listen('login',function(){
    echo 'user is login';
})
\EventListener\Event::fire('login');

// With parameter

\EventListener\Event::listen('login',function($username){
    echo "Hello $username";
})
\EventListener\Event::fire('login','Armia');
```

---

If you have multiple events and listeners, you can `listen` or `fire` them one after the other

```
\EventListener\Event::listen('event_one',function($name){
    echo "Hello $name";
})->listen(EventTwo::class, ListenerTwo::class)->listen('event_three', function(){});

// Fire events
\EventListener\Event::fire('event_one','Armia')->fire(new EventTwo())->fire('event_three');
```

If you want to delete the event, do so

```
\EventListener\Event::delete('event_name');
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

1181d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af6d6cd4238d0a9280e4caaabff0c1280f8540ac344cb485ded6468486a28070?d=identicon)[HASSAN-22](/maintainers/HASSAN-22)

---

Top Contributors

[![HASSAN-22](https://avatars.githubusercontent.com/u/63023595?v=4)](https://github.com/HASSAN-22 "HASSAN-22 (3 commits)")

---

Tags

phpeventlistenerevent listenerhasan

### Embed Badge

![Health badge](/badges/hasan-22-event-listener/health.svg)

```
[![Health](https://phpackages.com/badges/hasan-22-event-listener/health.svg)](https://phpackages.com/packages/hasan-22-event-listener)
```

###  Alternatives

[supervisorphp/event

Listen to Supervisor events in PHP

1442.4k](/packages/supervisorphp-event)

PHPackages © 2026

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