PHPackages                             quellabs/signal-hub - 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. quellabs/signal-hub

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

quellabs/signal-hub
===================

Type-safe signal/slot event system

1.1.1(1mo ago)0974MITPHP

Since May 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/quellabs/signal-hub)[ Packagist](https://packagist.org/packages/quellabs/signal-hub)[ RSS](/packages/quellabs-signal-hub/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (13)Used By (4)

SignalHub: Signal-Slot System for PHP
=====================================

[](#signalhub-signal-slot-system-for-php)

[![Latest Version](https://camo.githubusercontent.com/ce005124e8a655f6f6767b406cbda46c80fb49a090f944eaebe167e05998eabd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7175656c6c6162732f7369676e616c2d6875622e737667)](https://packagist.org/packages/quellabs/signal-hub)[![License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Downloads](https://camo.githubusercontent.com/8e7beb323eadea99a265d2213e585e0006297994af8fb8a75740f61ce9d1ad65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7175656c6c6162732f7369676e616c2d6875622e737667)](https://packagist.org/packages/quellabs/signal-hub)

A Qt-inspired signal-slot implementation for PHP. Loose coupling between components through automatic signal discovery, with PHP's type system handling slot type safety.

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

[](#installation)

```
composer require quellabs/signal-hub
```

Basic Usage
-----------

[](#basic-usage)

Declare signals as typed properties — your class needs no knowledge of the hub:

```
use Quellabs\SignalHub\Signal;

class MollieController {

    public Signal $paymentPaid;
    public Signal $paymentFailed;

    public function handleWebhook(array $data): void {
        $payment = $this->fetchPayment($data['id']);
        $payment->isPaid() ? $this->paymentPaid->emit($payment) : $this->paymentFailed->emit($payment);
    }
}
```

Connect using a `Slot` — a wrapper around a callable that gives it stable object identity. Signal owns connected Slots strongly, so inline Slots are always safe. Store a Slot as a property only if you need to call `disconnect()` explicitly later.

```
use Quellabs\SignalHub\Slot;

$hub->discoverSignals($controller);

// Connect directly if you hold a reference...
$controller->paymentPaid->connect(new Slot(fn(Payment $p) => ...));

// ...or via the hub if you don't
$hub->getSignal(MollieController::class, 'paymentPaid')
    ->connect(new Slot(fn(Payment $p) => ...));
```

Standalone signals work without any owning object:

```
$signal = new Signal('app.booted');
$signal->connect(new Slot(fn() => ...));
$signal->emit();
```

Framework Integration
---------------------

[](#framework-integration)

Call `discoverSignals()` from whatever instantiates your objects. The emitting class stays hub-unaware:

```
$hub->discoverSignals($controller);

try {
    $controller->handle($request);
} finally {
    $hub->unregisterSignals($controller);
}
```

Consumers connect in their constructor — no controller reference needed:

```
class InventoryService {
    public function __construct(SignalHub $hub) {
        $hub->getSignal(OrderController::class, 'orderPlaced')
            ->connect(new Slot([$this, 'onOrderPlaced']));
    }
}
```

Hub API
-------

[](#hub-api)

```
$hub->discoverSignals($controller);                      // discover Signal properties on an object
$hub->unregisterSignals($controller);                    // unregister all signals for an object
$hub->getSignal(MollieController::class, 'paymentPaid'); // look up by class name
$hub->getSignal('app.booted');                           // look up standalone signal
$hub->findSignals('payment.*');                          // wildcard search
$hub->findSignals('payment.*', $controller);             // wildcard + instance
```

Advanced Features
-----------------

[](#advanced-features)

**Priorities** — priority belongs to the connection, not the slot, so the same Slot can have different priorities on different signals:

```
$signal->connect($auditSlot, priority: 100);    // runs first
$signal->connect($cleanupSlot, priority: -10);  // runs last
```

**Shared slots** — a single Slot can be connected to multiple signals simultaneously:

```
$slot = new Slot([$this, 'handleChange']);
$signalA->connect($slot, priority: 5);
$signalB->connect($slot, priority: 10);

$signalA->disconnect($slot); // still connected to $signalB
```

**Explicit disconnect** — store the Slot as a property and call `disconnect()` when needed:

```
class InventoryListener {
    private Slot $handlePrePersist;

    public function __construct(UnitOfWork $unitOfWork) {
        $this->unitOfWork = $unitOfWork;
        $this->handlePrePersist = new Slot([$this, 'handlePrePersist']);
        $unitOfWork->signalPrePersist->connect($this->handlePrePersist);
    }

    public function detach(): void {
        $this->unitOfWork->signalPrePersist->disconnect($this->handlePrePersist);
    }
}
```

**Meta-signals** — react to hub activity:

```
$hub->signalRegistered()->connect(new Slot(function(Signal $signal) {
    if (str_starts_with($signal->getName(), 'payment.')) {
        $signal->connect(new Slot($this->auditLogger(...)));
    }
}));
```

Architecture
------------

[](#architecture)

Four classes, no traits:

- **`Signal`** — holds connections, emits to slots (`connect`, `disconnect`, `emit`, `isConnected`)
- **`Slot`** — wraps a callable with stable object identity; the unit of connection
- **`SignalHub`** — registry and rendezvous point (`discoverSignals`, `unregisterSignals`, `getSignal`, `findSignals`)
- **`SignalHubLocator`** — optional static accessor for use outside DI contexts

Signal owns its Slots via a plain array keyed by `spl_object_id()`, giving connections an unambiguous lifetime: a Slot stays connected until `disconnect()` is called or the Signal is destroyed. Object-owned signals on the hub are stored in a `WeakMap` so they are garbage collected automatically when the owning object goes out of scope.

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

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

Recently: every ~19 days

Total

12

Last Release

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57e4ab872b3e37536367f2d26b192df3d3bb6a6a1cebec9a104d14a6d2ffe157?d=identicon)[noescom](/maintainers/noescom)

### Embed Badge

![Health badge](/badges/quellabs-signal-hub/health.svg)

```
[![Health](https://phpackages.com/badges/quellabs-signal-hub/health.svg)](https://phpackages.com/packages/quellabs-signal-hub)
```

PHPackages © 2026

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