PHPackages                             nimbly/announce - 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. nimbly/announce

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

nimbly/announce
===============

PSR-14 event dispatcher with subscriber support.

2.1(1y ago)27.0kMITPHPPHP ^8.2CI passing

Since Nov 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nimbly/Announce)[ Packagist](https://packagist.org/packages/nimbly/announce)[ RSS](/packages/nimbly-announce/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (9)Used By (0)

Announce
========

[](#announce)

[![Latest Stable Version](https://camo.githubusercontent.com/43a1abbc00e319e65c2ff51b32f5ae80fa672a4d41e6ad18a68435a7deb43a40/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696d626c792f416e6e6f756e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nimbly/Announce)[![GitHub Workflow Status](https://camo.githubusercontent.com/fcd831fb5022f86380b83bc81b6db5be4ebe62bf71a67673fa93d5bf0964e3ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e696d626c792f616e6e6f756e63652f636f7665726167652e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/nimbly/Announce/actions/workflows/coverage.yml)[![Codecov branch](https://camo.githubusercontent.com/96f82b51297312d9790d9d857b36e7554f4297595468d38e38bc7be3504229d3/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6e696d626c792f616e6e6f756e63652f6d61737465723f7374796c653d666c61742d737175617265)](https://app.codecov.io/github/nimbly/Announce)[![License](https://camo.githubusercontent.com/02875c134d9f138f15bebfea00a1d0fac937ac4f10d4f7cf65dbfb5cd977ce6b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e696d626c792f416e6e6f756e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nimbly/Announce)

A simple framework agnostic PSR-14 event dispatcher for your event-driven application.

Features
--------

[](#features)

- Uses PHP's `#Attribute` feature to register class methods as event handlers
- Optional PSR-11 Container support
- Full autowiring support for your subscribers and listeners - Announce will inject not just the event but any needed services or other dependencies from your container!

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

[](#installation)

```
composer require nimbly/announce
```

Quick start
-----------

[](#quick-start)

### Create an event class

[](#create-an-event-class)

Your events can be standalone classes or they can extend the `StoppableEvent` abstract class. By extending the `StoppableEvent` abstract you gain the ability to stop event propogation if needed.

```
namespace App\Events;

use App\Models\User;
use Nimbly\Announce\Event;

class UserRegisteredEvent extends StoppableEvent
{
	public function __construct(public User $user)
	{
	}
}
```

### Create a subscriber

[](#create-a-subscriber)

Subscribers are classes that will handle your events. You can have as many subscribers as you would like.

To register a subscriber's method to handle a particular event or set of events, use the `Nimbly\Announce\Subscribe` attribute and pass in a comma separated list of event names to listen for.

```
namespace App\Subscribers;

use App\Events\UserRegisteredEvent;
use App\Services\EmailService;
use Nimbly\Announce\Subscribe;

class EmailSubscriber
{
	#[Subscribe(UserRegisteredEvent::class)]
	public function onUserRegistered(
		UserRegisteredEvent $event,
		EmailService $emailService): void
	{
		$emailService->send("registration_email", $event->user->email);
	}
}
```

### Initiate Dispatcher

[](#initiate-dispatcher)

To register your subscriber's with the event dispatcher, pass in an array of class names or instances into the `Dispatcher` constructor.

You can also pass in a PSR-11 compliant container instance to be used in autowiring your subscribers as well as for event handlers on your subscribers.

```
$dispatcher = new Dispatcher(
	subscribers: [
		EmailSubscriber::class,
		new FooSubscriber,
	],
	container: $container
);
```

### Dispatch event

[](#dispatch-event)

To trigger an event, just call the `dispatch` method with the event instance.

```
$event = new UserRegisteredEvent($user);
$dispatcher->dispatch($event);
```

### Stopping event propagation

[](#stopping-event-propagation)

If you need to stop event propagation during its lifetime, just call the `stop()` method on the event instance. The event will no longer be propagated to any further subscribed listeners. This requires the event to extend from the `StoppableEvent` abstract.

```
class UserRegisteredEvent extends StoppableEvent
{
	public function __construct(public User $user)
	{}
}
```

```
class EmailSubscriber
{
	#[Subscribe(UserRegisteredEvent::class)]
	public function onUserRegistered(
		UserRegisteredEvent $event,
		EmailService $emailService): void
	{
		$emailService->send("registration_email", $event->user->email);

		// Prevent any further handlers from processing this event
		$event->stop();
	}
}
```

### Registering individual listeners

[](#registering-individual-listeners)

Alternatively, you can register individual events using the `listen` method.

```
$dispatcher = new Dispatcher;
$dispatcher->listen(
	UserRegisteredEvent::class,
	function(UserRegisteredEvent $event): void {
		// do some event stuff
	}
);
```

### Wildcard listeners

[](#wildcard-listeners)

You can register a "wild card" listener by using the `*` event name. This will subscribe to *all* events fired.

```
$dispatcher = new Dispatcher;
$dispatcher->listen(
	"*",
	function($event): void {
		// Respond to all events...
	}
);
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance44

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity79

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

Recently: every ~491 days

Total

8

Last Release

445d ago

Major Versions

0.3.1 → 1.02022-09-06

1.0 → 2.02023-03-17

PHP version history (4 changes)0.2PHP &gt;=7.2

1.0PHP &gt;=8.0

2.0.1PHP ^8.0

2.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/723164?v=4)[Brent Scheffler](/maintainers/brentscheffler)[@brentscheffler](https://github.com/brentscheffler)

---

Top Contributors

[![brentscheffler](https://avatars.githubusercontent.com/u/723164?v=4)](https://github.com/brentscheffler "brentscheffler (42 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nimbly-announce/health.svg)

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

###  Alternatives

[symfony/event-dispatcher-contracts

Generic abstractions related to dispatching event

3.4k756.5M424](/packages/symfony-event-dispatcher-contracts)[league/event

Event package

1.6k141.6M184](/packages/league-event)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[yohang/finite

A simple PHP Finite State Machine

1.3k3.5M10](/packages/yohang-finite)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)

PHPackages © 2026

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