PHPackages                             bugadani/event\_source - 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. bugadani/event\_source

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

bugadani/event\_source
======================

A library to create event sources easily

1.0(10y ago)018MITPHPPHP &gt;=5.4

Since Feb 3Pushed 10y ago2 watchersCompare

[ Source](https://github.com/bugadani/EventSource)[ Packagist](https://packagist.org/packages/bugadani/event_source)[ RSS](/packages/bugadani-event-source/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

EventSource
===========

[](#eventsource)

EventSource is a simple library for PHP 5.4+ to create event source objects.

Usage
-----

[](#usage)

### EventSource trait

[](#eventsource-trait)

When you wish to make one of your classes an event source, simply use the EventSource trait in them and call the initializer method.

```
class SomeClass {
    use EventSource\EventSource;

    public function __construct() {
        //initialize defines the events that can be used
        $this->initialize(['fooEvent', 'barEvent']);
    }

    public function someMethod() {
        $this->raise('fooEvent', $someOptionalParameter);
    }
}

```

You can use the `on($eventName, $callback)` method to define event handlers which will be notified if the given event is raised.

```
$someObject = new SomeClass();
$someObject->on('fooEvent', function($someParameter = null) {
    //do something
});

```

You can also remove event handlers using the `remove($eventName, $callback)` method.

### Event class

[](#event-class)

Alternatively, you have the option to manually create Event objects that are used by EventSource to manage the event handlers. The Event class has the following methods:

- `on($callback)` - register a new callback to handle the event
- `remove($callback)` - removes a previously registered callback
- `raise(optional $parameter)` - raises the event

One downside is when using the Event class directly is that `raise()` is a public method, so any outside code may trigger events.

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

[](#installation)

### Using Composer

[](#using-composer)

```
"require": {
    "bugadani/event_source": "1.*"
}

```

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Every ~88 days

Total

2

Last Release

3760d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bugadani-event-source/health.svg)

```
[![Health](https://phpackages.com/badges/bugadani-event-source/health.svg)](https://phpackages.com/packages/bugadani-event-source)
```

###  Alternatives

[tatter/alerts

Lightweight user alerts for CodeIgniter 4

4083.9k6](/packages/tatter-alerts)[bobdenotter/weatherwidget

🌤 A simple Dashboard Widget that displays the current weather. So you don't actually need to go outside or open the curtains.

12156.9k1](/packages/bobdenotter-weatherwidget)

PHPackages © 2026

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