eventsauce/message-repository-table-schema
aggregate_id, message_type, payload, metadata), aligning with Laravel’s need for auditability and replayability. However, it assumes EventSaucePHP as the event bus, which may not align with Laravel’s native event system (e.g., Illuminate\Events). For CQRS, the package enables projection services but requires additional Laravel-specific glue code (e.g., read models).Event facade to EventSaucePHP’s MessageRepository. Example:
// Pseudocode: Laravel Event → EventSaucePHP Event
Event::listen('OrderCreated', function ($event) {
$domainEvent = new OrderCreatedEvent(
$event->orderId,
json_encode($event->details)
);
$messageRepository->save($domainEvent);
});
jobs table) may use integers or serialized arrays, requiring migration planning. For example:
jobs table, a data migration is needed to backfill the new schema.user_id, tenant_id) requires schema extensions.WHERE aggregate_id = ?), but complex joins could slow down projections.jobs table) need to coexist with this package, or is this a full replacement?schema.php)?jobs or elsewhere) be migrated to the new schema?jobs tables (less structured, no replayability).event_store).jobs table, custom tables, or no storage).composer require eventsauce/event-sauce eventsauce/message-repository-table-schema doctrine/dbal
config/app.php to include:
EventSauce\MessageRepositoryTableSchema\MessageRepositoryTableSchemaServiceProvider::class,
php artisan vendor:publish --provider="EventSauce\MessageRepositoryTableSchema\MessageRepositoryTableSchemaServiceProvider"
php artisan migrate
tenant_id):
Schema::table('message_store', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable();
});
class LaravelEventToDomainEventAdapter
{
public function __construct(private MessageRepository $messageRepository) {}
public function handle(LaravelEvent $event): void
{
$domainEvent = new DomainEvent(
$event->aggregateId,
$event->name,
json_encode($event->payload)
);
$this->messageRepository->save($domainEvent);
}
}
EventServiceProvider:
protected $listen = [
'OrderCreated' => [LaravelEventToDomainEventAdapter::class],
];
// Example: Project events to an Order model
$events = $messageRepository->load($aggregateId);
$order = new Order();
foreach ($events as $event) {
$order->apply($event);
}
$order->save();
.env: Ensure DB_CONNECTION matches the package’s expectations.How can I help you explore Laravel packages today?