PHPackages                             oihana/php-signals - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. oihana/php-signals

ActiveLibrary[Queues &amp; Workers](/categories/queues)

oihana/php-signals
==================

The Oihana PHP Signals library

1.0.2(4mo ago)017MPL-2.0PHPPHP &gt;=8.4CI passing

Since Nov 12Pushed 4mo agoCompare

[ Source](https://github.com/BcommeBois/oihana-php-signals)[ Packagist](https://packagist.org/packages/oihana/php-signals)[ Docs](https://github.com/BcommeBois/oihana-php-signals)[ RSS](/packages/oihana-php-signals/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

oihana-php-signals
==================

[](#oihana-php-signals)

[![Oihana PHP Signals](https://raw.githubusercontent.com/BcommeBois/oihana-php-signals/main/assets/images/oihana-php-signals-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-signals/main/assets/images/oihana-php-signals-logo-inline-512x160.png)

A fast and flexible signal/slot implementation for event-driven programming.

[![Latest Version](https://camo.githubusercontent.com/5b9770efb45498ac72ffc4990d8719c8ec8f8b6b03d1aa3e55c784d8e6454ee0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d7369676e616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-signals)
[![Total Downloads](https://camo.githubusercontent.com/50f98a7aec776e0586611b0e5eab96005a2db86e955c78ac9e0c14b9a5787833/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d7369676e616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-signals)
[![License](https://camo.githubusercontent.com/b318f13e478b5062dd7ccf4de54c619c30b09093dda5fd25eae67185364a8d14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d7369676e616c732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

📚 Documentation
---------------

[](#-documentation)

Full project documentation is available at:
👉

📦 Installation
--------------

[](#-installation)

> Requires [PHP 8.4+](https://php.net/releases/)

Install via Composer:

```
composer require oihana/php-signals
```

✨ Features
----------

[](#-features)

Provides a robust observer pattern implementation with priority-based execution, auto-disconnect capability, and support for both callable functions and Receiver objects. It is ideal for event-driven architectures and decoupled communication between components.

- Priority-based receiver execution (higher priority executes first)
- Auto-disconnect for one-time listeners
- Type-safe receiver management
- Efficient sorting and execution order
- Supports both object receivers implementing `Receiver` and PHP callables

🚀 Quick start
-------------

[](#-quick-start)

Basic usage with callables and Receiver objects.

```
use oihana\signals\Signal;
use oihana\signals\Receiver;

// Define a Receiver class
class NotificationHandler implements Receiver
{
    public function receive( mixed ...$values ) :void
    {
        echo 'Notification: ' . implode(', ', $values) . PHP_EOL;
    }
}

// Create receivers
$logger = function( mixed ...$values )
{
     echo 'Log: ' . implode(', ', $values) . PHP_EOL;
};

$handler = new NotificationHandler();

// Setup signal
$signal = new Signal();

// Connect with different priorities
$signal->connect( $logger  , priority: 10 ); // Executes first
$signal->connect( $handler , priority: 5 ); // Executes second

// Emit values to all connected receivers
$signal->emit( 'User logged in', 'user123' );

// One-time listener
$signal->connect
(
    fn() => echo 'First emit only!' . PHP_EOL,
    autoDisconnect: true
);
```

**Note :** WeakReferences are used for object receivers to allow proper garbage collection without preventing objects from being destroyed.

🧰 Usage
-------

[](#-usage)

Advanced usage with priority and auto-disconnect

```
$signal = new Signal();

// High priority handler (executes first)
$signal->connect
(
    fn($msg) => echo "URGENT: $msg" . PHP_EOL,
    priority: 100
);

// One-time handler (disconnects after first emit)
$signal->connect
(
    fn($msg) => echo "Initialization: $msg" . PHP_EOL,
    priority: 50,
    autoDisconnect: true
);

// Normal priority handler
$signal->connect
(
     fn($msg) => echo "Info: $msg" . PHP_EOL
);

// First emit - all three handlers execute
$signal->emit('System started');

// Second emit - only two handlers execute (auto-disconnect removed one)
$signal->emit('Processing data');
```

Running Unit Tests
------------------

[](#running-unit-tests)

To run all tests:

```
$ composer test
```

To run a specific test file:

```
$ composer test tests/oihana/signals/SignalTest.php
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Whether you're fixing a bug, improving an existing feature, or proposing a new one, your help is appreciated.

Please feel free to:

- **Report a bug:** If you find a bug, please open an issue and provide as much detail as possible.
- **Suggest an enhancement:** Have an idea to make this library better? Open an issue to discuss it.
- **Submit a pull request:** Fork the repository, make your changes, and open a pull request. Please ensure all tests are passing before submitting.

You can find the issues page here:

🗒️ Changelog
------------

[](#️-changelog)

See `CHANGELOG.md` for notable changes.

License
-------

[](#license)

This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).

👤 About the author
------------------

[](#-about-the-author)

- Author : Marc ALCARAZ (aka eKameleon)
- Mail :
- Website :

🛠️ Generate the Documentation
-----------------------------

[](#️-generate-the-documentation)

We use [phpDocumentor](https://phpdoc.org/) to generate the documentation into the `./docs` folder.

🔗 Related packages
------------------

[](#-related-packages)

- `oihana/php-core` – core helpers and utilities used by this library: `https://github.com/BcommeBois/oihana-php-core`
- `oihana/php-reflect` – reflection and hydration utilities: `https://github.com/BcommeBois/oihana-php-reflect`

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance78

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

Total

3

Last Release

120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d234506e51778dd3d1d61b6c2af6f294ff963651b4aa509b595d3d2a77b7d89b?d=identicon)[ooop](/maintainers/ooop)

---

Top Contributors

[![ekameleon](https://avatars.githubusercontent.com/u/749032?v=4)](https://github.com/ekameleon "ekameleon (8 commits)")

---

Tags

messagephpsignalsreceivernotice

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oihana-php-signals/health.svg)

```
[![Health](https://phpackages.com/badges/oihana-php-signals/health.svg)](https://phpackages.com/packages/oihana-php-signals)
```

###  Alternatives

[nahid/talk

Talk is a Laravel based realtime messaging, chatting and conversation system. It helps to develop users messaging, chatting and conversations in easy way.

1.6k58.1k4](/packages/nahid-talk)[baklysystems/laravel-chat-messenger

Laravel chat package

121.8k](/packages/baklysystems-laravel-chat-messenger)

PHPackages © 2026

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