PHPackages                             duyler/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. duyler/event-bus

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

duyler/event-bus
================

Duyler event bus

1782PHPCI passing

Since Mar 27Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Event Bus
=========

[](#event-bus)

[![Quality Gate Status](https://camo.githubusercontent.com/ff199f6d9d1f1793ec95f25be19420b662040038b5e6cf8e1fae00616cb62701/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6475796c65725f6576656e742d627573266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=duyler_event-bus)[![Coverage](https://camo.githubusercontent.com/993c8e9902d6cb7efa579c51672e50971081bab52ae41440f87249b9b202e71e/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6475796c65725f6576656e742d627573266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=duyler_event-bus)[![type-coverage](https://camo.githubusercontent.com/b9cdc3fa6dd845c74dd993d6606aab10233adff2954295740c4f7ef7c7eb0747/68747470733a2f2f73686570686572642e6465762f6769746875622f6475796c65722f6576656e742d6275732f636f7665726167652e737667)](https://shepherd.dev/github/duyler/event-bus)[![psalm-level](https://camo.githubusercontent.com/479f528051f013cef41e0cba5caa8e936ac48aafd31a2e75aeb4f586e0ead0ba/68747470733a2f2f73686570686572642e6465762f6769746875622f6475796c65722f6576656e742d6275732f6c6576656c2e737667)](https://shepherd.dev/github/duyler/event-bus)[![PHP Version](https://camo.githubusercontent.com/2542f75adf36486fc90d79ac0beafff7ff1562a34ffd277db9f05d98cf4d7eae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6475796c65722f6576656e742d6275732f7068703f76657273696f6e3d6465762d6d61696e)](https://camo.githubusercontent.com/2542f75adf36486fc90d79ac0beafff7ff1562a34ffd277db9f05d98cf4d7eae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6475796c65722f6576656e742d6275732f7068703f76657273696f6e3d6465762d6d61696e)

The event bus implements cooperative multitasking between actors performed inside it. Each actor is performed inside a separate thread (Fiber) in an isolated DI container. Execution can be controlled using state handlers, events, and triggers to messages generated by actors.

Full documentation see [RU](https://github.com/duyler/docs/tree/main/pages/ru) [EN](https://github.com/duyler/docs/tree/main/pages/en)

Reactive Subscriptions
----------------------

[](#reactive-subscriptions)

The event bus supports reactive subscriptions that allow actors to subscribe to events with status consideration.

### onOne - Subscribe to a single event

[](#onone---subscribe-to-a-single-event)

Subscribe to a single event with status consideration:

```
use Duyler\EventBus\Build\Actor;
use Duyler\EventBus\Build\Id;

new Actor(
    id: 'SendNotification',
    handler: SendNotificationHandler::class,
    onOne: Id::success('CreateOrder'),
    argument: Order::class,
);
```

Subscribe to a Fail status:

```
new Actor(
    id: 'HandleFailure',
    handler: HandleFailureHandler::class,
    onOne: Id::fail('ProcessPayment'),
);
```

### onAny - Subscribe to any of the events

[](#onany---subscribe-to-any-of-the-events)

Execute when any of the specified events occur:

```
use Duyler\EventBus\Build\Id;

new Actor(
    id: 'LogActivity',
    handler: LogActivityHandler::class,
    onAny: [
        Id::success('CreateOrder'),
        Id::success('UpdateOrder'),
    ],
);
```

### onAll - Subscribe to all events

[](#onall---subscribe-to-all-events)

Execute only when all specified events occur:

```
new Actor(
    id: 'CompleteCheckout',
    handler: CompleteCheckoutHandler::class,
    onAll: [
        Id::success('ValidateCart'),
        Id::success('ProcessPayment'),
    ],
);
```

### External Events

[](#external-events)

External events require a status:

```
use Duyler\EventBus\Build\Event;

$builder->addEvent(Event::success('OrderCreated', OrderDTO::class));
$builder->addEvent(Event::fail('PaymentFailed'));
```

Dispatch external events:

```
use Duyler\EventBus\Dto\Event;

$bus->dispatchEvent(new Event(
    id: 'OrderCreated.Success',
    data: new OrderDTO(orderId: '123'),
));
```

### Silent Actors

[](#silent-actors)

Silent actors do not generate events:

```
new Actor(
    id: 'InternalProcess',
    handler: InternalProcessHandler::class,
    silent: true,
);
```

Scheduler
---------

[](#scheduler)

Event Bus includes a built-in task scheduler for executing periodic operations.

### Adding Scheduled Tasks

[](#adding-scheduled-tasks)

```
use Duyler\EventBus\Dto\ScheduledTask;

$busBuilder->addScheduledTask(new ScheduledTask(
    callback: function (): void {
        // Periodic task logic
    },
    intervalMs: 1000,       // Execute every 1000ms
    startDelayMs: 500,      // Optional: delay before first run
));
```

### GC Tasks

[](#gc-tasks)

By default, Event Bus registers two garbage collection tasks:

- `GcCollectCyclesTask` - collects GC cycles
- `GcMemCachesTask` - clears memory caches

Configure intervals through `BusConfig`:

```
use Duyler\EventBus\BusConfig;

new BusConfig(
    gcCollectCyclesInterval: 120000, // 2 minutes
    gcMemCachesInterval: 60000,      // 1 minute
);
```

### Configuration

[](#configuration)

```
new BusConfig(
    schedulerCheckInterval: 100, // Task check interval (ms)
);
```

### Scheduler API

[](#scheduler-api)

**ScheduledTask DTO**

PropertyTypeDescription`callback``callable`Function to execute periodically`intervalMs``int`Execution interval in milliseconds`startDelayMs``int|null`Optional delay before first execution**BusConfig Scheduler Options**

OptionTypeDefaultDescription`schedulerCheckInterval``int``100`Interval between task checks (ms)`gcCollectCyclesInterval``int``120000`GC cycle collection interval (ms)`gcMemCachesInterval``int``60000`Memory cache cleanup interval (ms)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance59

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/69f18edde71f0f80540eda4e097854eddf8eb3390f38ff2ad241b9daaf622281?d=identicon)[milinsky](/maintainers/milinsky)

---

Top Contributors

[![milinsky](https://avatars.githubusercontent.com/u/17288321?v=4)](https://github.com/milinsky "milinsky (592 commits)")

### Embed Badge

![Health badge](/badges/duyler-event-bus/health.svg)

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

PHPackages © 2026

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