chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
[](https://github.com/blax-software)
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
# ReactPHP Kernel
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
[](https://php.net)
[](https://reactphp.org)
[](#testing)
[](#testing)
[](LICENSE)
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
A tiny, protocol-agnostic ReactPHP backbone — one long-lived process, one event loop, one IPC primitive, and one graceful-shutdown story that many protocol servers attach to.
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
## Features
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
- 🧩 **One loop, many protocols** — WebSockets, WebRTC signaling, SIP and more share a single `Kernel` instead of each spinning up its own runtime
- 🔌 **Tiny `Server` contract** — implement `boot(LoopInterface)` + `shutdown()` and you're on the shared loop
- 🧵 **Socket-pair IPC** — event-driven parent↔child messaging with zero polling
- 🛎️ **Graceful shutdown** — SIGINT/SIGTERM tear every server down cleanly before the loop stops
- 🧹 **Child reaping built in** — no zombie processes from forked workers (SIGCHLD + periodic backstop)
- 🔐 **Plain or TLS listeners** — one factory, no framework coupling
- 🪶 **Dependency-light** — just `react/event-loop` , `react/socket` , `react/stream`
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
## Installation
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
```bash
composer require blax-software/reactphp-kernel
2026-07-07 11:07:47 +00:00
```
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
Requires PHP 8.1+, plus `ext-pcntl` (signals + child reaping) and `ext-sockets` (IPC) for the full feature set.
## Quick Start
Implement a `Server` , register it, `run()` :
2026-07-07 11:07:47 +00:00
```php
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
use Blax\ReactPhpKernel\Kernel;
use Blax\ReactPhpKernel\Contracts\Server;
use Blax\ReactPhpKernel\Server\SocketServerFactory;
2026-07-07 11:07:47 +00:00
use React\EventLoop\LoopInterface;
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
use React\Socket\ConnectionInterface;
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
final class EchoServer implements Server
2026-07-07 11:07:47 +00:00
{
private $socket = null;
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
public function name(): string
{
return 'echo';
}
2026-07-07 11:07:47 +00:00
public function boot(LoopInterface $loop): void
{
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
$this->socket = SocketServerFactory::create('0.0.0.0:9001', $loop);
$this->socket->on('connection', function (ConnectionInterface $conn) {
$conn->on('data', fn ($data) => $conn->write($data)); // echo it back
});
2026-07-07 11:07:47 +00:00
}
public function shutdown(): void
{
$this->socket?->close();
}
}
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
(new Kernel())
->reapChildren() // auto-reap forked children
->register(new EchoServer())
->onBoot(fn (Kernel $k) => fwrite(STDERR, "ready\n"))
->run(); // boots servers, installs signals, runs the loop (blocks)
2026-07-07 11:07:47 +00:00
```
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
`Ctrl-C` (SIGINT) or `SIGTERM` triggers a graceful `stop()` : every registered server's `shutdown()` runs, then the loop stops.
2026-07-07 11:07:47 +00:00
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
## What's in the box
| Class | Responsibility |
|---|---|
| `Kernel` | Owns the loop; `register()` servers; installs signals; `run()` / graceful `stop()` . |
| `Contracts\Server` | An attachable protocol server: `boot(LoopInterface)` (non-blocking) + `shutdown()` . |
| `Server\SocketServerFactory` | Plain-TCP or TLS listening socket. |
| `Ipc\SocketPairIpc` | Event-driven parent/child IPC over a Unix socket pair. |
| `Process\SignalHandler` | SIGINT/SIGTERM → graceful shutdown. |
| `Process\ChildReaper` | Reaps exited forked children (SIGCHLD + periodic backstop). |
## Why
It's the shared foundation extracted from [`blax-software/laravel-websockets` ](https://github.com/blax-software/laravel-websockets ) so that WebSockets and [`blax-software/laravel-webrtc` ](https://github.com/blax-software/laravel-webrtc ) (WebRTC signaling + a Rust/str0m media core) don't each re-implement the loop, IPC, signals and supervision. A new protocol gets the plumbing for free.
```
reactphp-kernel this package — the backbone
├─ laravel-websockets WS on the kernel
└─ laravel-webrtc WebRTC signaling on the kernel
└─ Rust/str0m core via ext-php-rs
```
## Testing
```bash
composer install
composer test
```
The suite runs against a real ReactPHP loop, with no external services.
2026-07-07 11:07:47 +00:00
## License
chore: finish package to Blax standard (namespace, README, tests, scaffolding)
- Rename namespace BlaxSoftware\ReactPhpKernel -> Blax\ReactPhpKernel (house
standard; the BlaxSoftware\LaravelWebSockets form is grandfathered only there)
- README rewritten to the Blax OSS package principles: OSS banner, title+badges,
emoji feature list, quick start, what's-in-the-box, testing, star history
- Add PHPUnit suite (13 tests / 19 assertions, green) + phpunit.xml.dist
- Add pint.json (laravel preset, applied), composer scripts (test/lint),
.gitattributes export-ignores, test.sh (nix), CHANGELOG
- composer.json: Blax psr-4, PHP ^8.1-^8.4, dev deps
rel learn-atc #1055
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:24:36 +00:00
MIT. See [LICENSE ](LICENSE ).
## Star History
< a href = "https://www.star-history.com/?repos=blax-software%2Freactphp-kernel&type=date&legend=top-left" >
< picture >
< source media = "(prefers-color-scheme: dark)" srcset = "https://api.star-history.com/chart?repos=blax-software/reactphp-kernel&type=date&theme=dark&legend=top-left" / >
< source media = "(prefers-color-scheme: light)" srcset = "https://api.star-history.com/chart?repos=blax-software/reactphp-kernel&type=date&legend=top-left" / >
< img alt = "Star History Chart" src = "https://api.star-history.com/chart?repos=blax-software/reactphp-kernel&type=date&legend=top-left" / >
< / picture >
< / a >