Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Event Projector Laravel Package

spatie/laravel-event-projector

Deprecated in favor of spatie/laravel-event-sourcing. Entry-level event sourcing toolkit for Laravel: define aggregates, projectors, and reactors; persist domain events, build read models, and react to events for auditing and reporting-friendly apps.

View on GitHub
Deep Wiki
Context7

title: Adding and Removing Projectors and Reactors weight: 10

You can add and remove projectors and reactors via the Projectionist facade.

Whilst this package can auto-discover your event handlers, it is still useful to be able to add and remove projectors or reactors for your test suite. For example, a slow reactor might be worth removing to speed up your tests if the behaviour of that reactor is not relevant for the feature you are testing.

Adding Projectors

Adding one projector:

Projectionist::addProjector(TransactionCountProjector::class);

Adding many projectors:

Projectionist::addProjector([
    AccountBalanceProjector::class,
    TransactionCountProjector::class,
]);

Adding Reactors

Adding one reactor:

Projectionist::addReactor(SendMailReactor::class);

Adding many reactors:

Projectionist::addReactor([
    SendMailReactor::class,
    SendPushNotificationReactor::class,
]);

Removing Projectors and Reactors

A projector and a reactor are both event handlers. You can remove either of them with the same function.

Removing one event handler:

Projectionist::withoutEventHandler(SendPushNotificationReactor::class);

Removing many event handlers:

Projectionist::withoutEventHandlers([
    TransactionCountProjector::class,
    SendPushNotificationReactor::class,
]);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport