Type-safe actors, supervision trees, event sourcing, multi-process clustering.
Erlang/OTP and Akka patterns — in the PHP you already know.
// Define messages
readonly class Ping {
public function __construct(public ActorRef $replyTo) {}
}
readonly class Pong {}
// Define actor behavior
$pongActor = Behavior::receive(
static fn(ActorContext $ctx, Ping $msg) => $msg->replyTo->tell(new Pong()) ?? Behavior::same(),
);
// Spawn and interact
$system = ActorSystem::create('my-app', new FiberRuntime());
$ref = $system->spawn(Props::fromBehavior($pongActor), 'pong');
$response = $ref->ask(fn(ActorRef $replyTo) => new Ping($replyTo), Duration::seconds(5));
// $response is Pong- Type-safe actors — Generic
ActorRef<T>,Behavior<T>,Props<T>with Psalm level 1 enforcement - Supervision trees — One-for-one, all-for-one, exponential backoff with custom exception deciders
- Event sourcing & durable state — Persist events or state snapshots with automatic crash recovery
- Pluggable runtimes — Write once, run on PHP Fibers (dev) or Swoole coroutines (production)
- Multi-process clustering — Consistent hash ring, location-transparent
RemoteActorRef, Unix socket transport - Custom Psalm plugin — 7 actor-specific static analysis rules catch concurrency bugs at compile time
| Package | Description |
|---|---|
| nexus | Monorepo & meta-package |
| core | Actors, behaviors, supervision, mailboxes |
| runtime-fiber | PHP Fiber runtime |
| runtime-swoole | Swoole coroutine runtime |
| runtime-step | Deterministic test runtime |
| app | Application bootstrap with PSR-11 |
| serialization | Message serialization |
| persistence | Event sourcing & durable state |
| persistence-dbal | DBAL persistence store |
| persistence-doctrine | Doctrine persistence store |
| cluster | Multi-process clustering |
| cluster-swoole | Swoole cluster transport |
| psalm | Actor-specific Psalm plugin |
composer require nexus-actors/nexusNexusApp::create('my-app')
->actor('greeter', Props::fromBehavior($greeterBehavior))
->onStart(function (ActorSystem $system) {
$system->spawn(Props::fromBehavior($greeterBehavior), 'greeter')
->tell(new Greet('world'));
})
->run(new FiberRuntime());Backed by Monadial · MIT License