PHPackages                             earc/observer - 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. [Framework](/categories/framework)
4. /
5. earc/observer

ActiveLibrary[Framework](/categories/framework)

earc/observer
=============

eArc - the explicit architecture framework - psr-14 compatible observer blueprint

1.1(5y ago)0131↓50%2MITPHPPHP ^7.2 || ^8.0

Since Jul 17Pushed 5y agoCompare

[ Source](https://github.com/Koudela/eArc-observer)[ Packagist](https://packagist.org/packages/earc/observer)[ RSS](/packages/earc-observer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (2)

eArc-observer
=============

[](#earc-observer)

earc/observer is a ready to use and extendable psr-14 compatible observer blueprint.

Install
-------

[](#install)

```
$ composer require earc/observer
```

Bootstrap
---------

[](#bootstrap)

earc/observer uses [earc/di](https://github.com/Koudela/eArc-di) for dependency injection.

```
use eArc\DI\DI;

DI::init();
```

Place the above code in the section where your script/framework is bootstrapped.

Configure
---------

[](#configure)

earc/observer does not need any configuration.

Use
---

[](#use)

### The event

[](#the-event)

Your event has to implement the [EventInterface](https://github.com/Koudela/eArc-observer/blob/master/src/Interfaces/EventInterface.php)in order to be dispatchable by the dispatcher of earc/observer.

```
use eArc\Observer\Interfaces\EventInterface;
use eArc\Observer\Interfaces\ListenerInterface;

class SomeEvent implements EventInterface
{
    public static function getApplicableListener(): array
    {
        return [ListenerInterface::class];
    }
}
```

Extend the ListenerInterface if you want to be more specific.

### Register Listeners

[](#register-listeners)

You can either use the observer object to register your listener

```
use eArc\Observer\Observer;

$observer = di_get(Observer::class);

$observer->registerListener(SomeListener::class);
```

or use the tagging of earc/di (if the observer instance is not build yet)

```
use eArc\Observer\Observer;

di_tag(Observer::class, SomeListener::class);
```

Hint: Tagging does not initialize the observer nor does it autoload the observer class. Both does not autoload the listener until it is called upon to process the event.

### Patience

[](#patience)

If you pass a `float` as second or third argument respectively, it is interpreted as patience. The more patience the listener has the later it is called.

```
use eArc\Observer\Observer;

$observer = di_get(Observer::class);

$observer->registerListener(SomeListener::class, 0.2);
```

or (if the observer instance is not build yet)

```
use eArc\Observer\Observer;

di_tag(Observer::class, SomeListener::class, -12.7);
```

### Unregister Listeners

[](#unregister-listeners)

You can unregister by

```
$observer->unregisterListener(SomeListener::class);
```

or (if the observer instance is not build yet)

```
use eArc\Observer\Observer;

di_clear_tags(Observer::class, SomeListener::class);
```

Note the different semantics of `di_tag()` and `di_clear_tags()`.

### Dispatch the event

[](#dispatch-the-event)

To dispatch your event use the dispatcher

```
use eArc\Observer\Dispatcher;

$dispatcher = di_get(Dispatcher::class);
$event = $dispatcher->dispatch($event);
```

It returns the event that may be modified by the listener.

advanced usage
--------------

[](#advanced-usage)

If you want to change the behaviour of the observer you can decorate it by any class implementing the `ObserverInterface`.

```
use \eArc\Observer\Interfaces\ObserverInterface;

di_decorate(ObserverInterface::class, TheNewObserver::class);
```

Please note that every library in your project, using earc/observer, uses the decorating class thereafter. Therefore you might be forced to write your own dispatcher too. All you need to do is implementing the `DispatcherInterface`.

releases
--------

[](#releases)

### release 1.1

[](#release-11)

- PHP ^7.2 || ^8.0

### release 1.0.3

[](#release-103)

- fix patience via tag converts float to int
- documentation completed
- test coverage 100% of documented features

### release 1.0.2

[](#release-102)

- fix php does not recognise \['string' =&gt; $obj, 'method'\] as callable.

### release 1.0.1

[](#release-101)

- added listener interface

### release 1.0

[](#release-10)

- rewrite to be psr-14 compatible

### release 0.0

[](#release-00)

- initial release

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity68

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 ~130 days

Recently: every ~160 days

Total

6

Last Release

1843d ago

Major Versions

0.0 → 1.02019-07-24

PHP version history (2 changes)0.0PHP ^7.2

1.1PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7308f2797252cace014cfec12c1b5978c1bf5608be78d7a188ff690192959f3?d=identicon)[Thomas Koudela](/maintainers/Thomas%20Koudela)

---

Top Contributors

[![Koudela](https://avatars.githubusercontent.com/u/21366492?v=4)](https://github.com/Koudela "Koudela (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/earc-observer/health.svg)

```
[![Health](https://phpackages.com/badges/earc-observer/health.svg)](https://phpackages.com/packages/earc-observer)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[spiral/framework

Spiral, High-Performance PHP/Go Framework

2.0k1.8M57](/packages/spiral-framework)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[typo3/cms-core

TYPO3 CMS Core

3512.3M3.8k](/packages/typo3-cms-core)

PHPackages © 2026

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