Nexus API Reference

PersistenceId
in package
implements Stringable

Read onlyYes
FinalYes

Unique stable identity for a persistent actor.

A PersistenceId combines an entity type (e.g. "Order") with an entity ID (e.g. "order-42") and serialises to "Order|order-42". The separator is a pipe character (|) which is forbidden in the entity type to ensure unambiguous round-trip parsing.

All event-store and state-store operations use the persistence ID as the primary key. Choose IDs that are stable across restarts — typically the domain entity's UUID or slug.

Example:

$id = PersistenceId::of('Order', 'order-42');
echo $id; // "Order|order-42"

$same = PersistenceId::fromString('Order|order-42');
$id->equals($same); // true
Tags
see
EventSourcedBehavior

for using a PersistenceId in event-sourced actors

see
DurableStateBehavior

for using a PersistenceId in durable-state actors

psalm-api

Table of Contents

Interfaces

Stringable

Properties

$entityId  : string
$entityType  : string

Methods

__toString()  : string
equals()  : bool
Return true if both entity type and entity ID match.
fromString()  : self
Parse a persistence ID from its canonical `"EntityType|entityId"` string form.
of()  : self
Create a persistence ID from separate entity type and entity ID strings.
toString()  : string
Return the canonical `"EntityType|entityId"` string representation.

Properties

Methods

__toString()

public __toString() : string
Return values
string

equals()

Return true if both entity type and entity ID match.

public equals(self $other) : bool
Parameters
$other : self
Return values
bool

fromString()

Parse a persistence ID from its canonical `"EntityType|entityId"` string form.

public static fromString(string $value) : self
Parameters
$value : string
Tags
throws
InvalidArgumentException

if the string does not contain a pipe separator

Return values
self

of()

Create a persistence ID from separate entity type and entity ID strings.

public static of(string $entityType, string $entityId) : self
Parameters
$entityType : string
$entityId : string
Tags
throws
InvalidArgumentException

if either argument is empty or entity type contains |

Return values
self

toString()

Return the canonical `"EntityType|entityId"` string representation.

public toString() : string
Return values
string

        
On this page

Search results