kislayphp / eventbus
High-performance C++ PHP extension providing realtime event protocol-compatible realtime communication for PHP microservices
Package info
Language:Shell
Type:php-ext
Ext name:ext-kislayphp_eventbus
pkg:composer/kislayphp/eventbus
0.0.2
2026-03-02 15:30 UTC
Requires
- php: >=8.2
Suggests
- kislayphp/config: Dynamic configuration management
- kislayphp/core: HTTP/HTTPS server foundation
- kislayphp/discovery: Service discovery integration
- kislayphp/gateway: API gateway with real-time features
- kislayphp/metrics: Real-time metrics monitoring
- kislayphp/queue: Message queuing integration
Provides
README
Realtime event transport for KislayPHP.
Primary runtime namespace is Kislay\EventBus with backward-compatible aliases under KislayPHP\EventBus.
Concurrency Mode
- EventBus is event-driven at runtime (connection loop + callbacks).
- Server APIs are callback-based and suitable for realtime workloads.
- This is one of the async/event-driven modules in the ecosystem policy.
Installation
pie install kislayphp/eventbus
Enable in php.ini:
extension=kislayphp_eventbus.so
Public API
Kislay\EventBus\Server:
__construct()on(string $event, callable $handler): boolemit(string $event, mixed $data): boolpublish(string $event, mixed $data): bool(alias)send(string $event, mixed $data): bool(alias)emitTo(string $room, string $event, mixed $data): boollisten(string $host, int $port, string $path): bool
Kislay\EventBus\Socket:
id(): stringjoin(string $room): boolleave(string $room): boolemit(string $event, mixed $data): boolpublish(string $event, mixed $data): bool(alias)send(string $event, mixed $data): bool(alias)reply(string $event, mixed $data): boolemitTo(string $room, string $event, mixed $data): bool
Legacy aliases:
KislayPHP\EventBus\ServerKislayPHP\EventBus\Socket
Quick Start
<?php $server = new Kislay\EventBus\Server(); $server->on('connection', function (Kislay\EventBus\Socket $socket) use ($server) { $socket->join('general'); $socket->reply('connected', ['id' => $socket->id()]); $server->on('chat', function (Kislay\EventBus\Socket $client, $payload) use ($server) { $server->emitTo('general', 'chat', $payload); }); }); $server->listen('0.0.0.0', 3000, '/events/');
Notes
- Use EventBus for realtime push/fanout.
- For request/response HTTP and middleware, use
kislayphp/core. - For queue semantics, use
kislayphp/queue.