Thanks to visit codestin.com
Credit goes to github.com

Skip to content
@nexus-actors

Nexus Actors

A typed actor system for PHP 8.5+

Nexus

A typed actor system for PHP 8.5+   WIP

Type-safe actors, supervision trees, event sourcing, multi-process clustering.
Erlang/OTP and Akka patterns — in the PHP you already know.

Documentation · Quick Start · GitHub


// 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

Key Features

  • 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

Packages

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

Get Started

composer require nexus-actors/nexus
NexusApp::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

Popular repositories Loading

  1. nexus nexus Public

    Concurrent PHP, done right.

    PHP

  2. core core Public

    Read-only subtree split of monadial/nexus. Submit issues and PRs to the main repository.

    PHP

  3. serialization serialization Public

    Read-only subtree split of monadial/nexus. Submit issues and PRs to the main repository.

    PHP

  4. runtime-fiber runtime-fiber Public

    Read-only subtree split of monadial/nexus. Submit issues and PRs to the main repository.

    PHP

  5. runtime-swoole runtime-swoole Public

    Read-only subtree split of monadial/nexus. Submit issues and PRs to the main repository.

    PHP

  6. runtime-step runtime-step Public

    Read-only subtree split of monadial/nexus. Submit issues and PRs to the main repository.

    PHP

Repositories

Showing 10 of 18 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…