Skip to main content

nexus-app

Declarative bootstrap kernel for single-process Nexus applications.

What's in this package

  • NexusApp — fluent builder that registers actors and starts the event loop
  • ActorDefinition — immutable value object pairing an actor name with its Props

Install

composer require nexus-actors/app

Quick example

src/bootstrap.php
use Monadial\Nexus\App\NexusApp;
use Monadial\Nexus\Runtime\Swoole\SwooleRuntime;

NexusApp::create('my-app')
->actor('orders', Props::fromBehavior($orderBehavior))
->actor('payments', Props::fromFactory(fn() => new PaymentActor()))
->onStart(function (ActorSystem $system): void {
// Called after all actors are spawned.
})
->run(new SwooleRuntime());

run() starts the runtime event loop and blocks until the system shuts down. All registered actors are spawned under /user before onStart fires.

For multi-worker deployments, use WorkerPoolApp or WorkerPoolBootstrap from nexus-worker-pool-swoole instead.

See also