Download the PHP package pektiyaz/laravel-event-engine without Composer
On this page you can find all versions of the php package pektiyaz/laravel-event-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pektiyaz/laravel-event-engine
More information about pektiyaz/laravel-event-engine
Files in pektiyaz/laravel-event-engine
Package laravel-event-engine
Short Description Event Driven Core for laravel applications
License MIT
Informations about the package laravel-event-engine
EventEngine for Laravel
EventEngine is a powerful and declarative extension for Laravel’s event system, providing a clear can → do → after pattern for modular business logic.
Installation
Features
Method Description
- can() Checks if the action is allowed before proceeding
- do() Performs an action and expects a success/failure response
- doAtomic() Performs an action inside a DB transaction (rollback-safe)
- after() Fires events that don’t affect control flow
Listener Contracts
can(...) listeners:
Must return:
do(...) listeners:
Must return:
ask(...) listeners:
Must return:
after(...) listeners:
Should not return anything. These may implement ShouldQueue.
Setup
Create an event and a listener for can(), do(), or after() patterns.
Register the listener in Laravel (EventServiceProvider).
1. Create an Event
Example: CanClientPay
2. Create a Listener
Listener that handles this event and returns a EventCanValue response.
Note: Always return an array from the listener (for can() and do() usage).
3. Register the Listener
Open app/Providers/EventServiceProvider.php and add your event + listener:
Then run:
Usage Examples
can() — check permission
do() — execute an action
doAtomic() — run EventEngine::do in DB transaction
after() — fire an event without expecting a response
ask() — collect data from listeners and returning array of answers
With Listener name
Why use EventEngine?
-
Clear separation of responsibilities (can, do, after)
-
Easy to test and maintain
-
Decouples business logic from the framework
-
Centralized event orchestration
- Scales well with modular systems
Coming Soon (ideas)
-
Configurable behavior via config file
-
failFast and collectAllErrors options
-
Automatic event registration
- Publishable Laravel package with service provider