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
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
$entityId
public
string
$entityId
$entityType
public
string
$entityType
Methods
__toString()
public
__toString() : string
Return values
stringequals()
Return true if both entity type and entity ID match.
public
equals(self $other) : bool
Parameters
- $other : self
Return values
boolfromString()
Parse a persistence ID from its canonical `"EntityType|entityId"` string form.
public
static fromString(string $value) : self
Parameters
- $value : string
Tags
Return values
selfof()
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
Return values
selftoString()
Return the canonical `"EntityType|entityId"` string representation.
public
toString() : string