event-engine/php-data
Immutable PHP value objects and data containers for event-driven apps. Provides typed properties, casting, validation, and convenient hydration from arrays/JSON, plus serialization back to payloads—useful for messages, commands, events, and read models in Event Engine setups.
JsonSerializable support (v2.1.0) improves interoperability with PHP’s native json_encode()/json_decode(), reducing reliance on custom serialization logic.@Assert\*) persist, ensuring robust data integrity.JsonSerializable integration simplifies serialization for APIs, databases (e.g., PostgreSQL jsonb), and message brokers (e.g., Kafka, RabbitMQ).JsonSerializable reduces serialization costs.JsonSerializable) are additive; no breaking changes in v2.1.0. However, future Event Engine updates could require adjustments.JsonSerializable improve performance vs. custom serialization (e.g., toArray())?JsonSerializable events?json_encode)?JsonSerializable-compatible events?__set overrides, read-only properties)?JsonSerializable events incrementally.JsonSerializable (e.g., json_encode($event)).@Assert\Email).jsonb with native json_encode()/json_decode().serialize() may still be needed for complex types).JsonSerializable events.JsonSerializable).Event).JsonSerializable events.Event base class (now with JsonSerializable).json_encode($event->toArray()) with json_encode($event).jsonSerialize() or toArray().v1/v2 events).JsonSerializable reduces serialization complexity; immutable objects are self-documenting.json_encode($event) or var_dump($event).JsonSerializable reduces serialization costs.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid event data | Downstream service crashes | Use try-catch for validation exceptions. |
| JSON serialization errors | Events fail to transmit/store | Validate schema before serialization. |
| Event Engine outage | Event processing halts | Implement dead-letter queues. |
| Schema evolution conflicts | Old consumers break on new events | Use backward-compatible event versions. |
| Memory leaks in event storage | High DB/RAM usage | Archive old events; use TTL in Redis. |
JsonSerializable usage.JsonSerializable immutable objects.How can I help you explore Laravel packages today?