Description
This library emulates several aspects of how events are triggered and managed in popular JavaScript libraries such as jQuery: An event object is dispatched to all listeners. The event object holds information about the event, and provides the ability to stop event propagation at any point. Listeners can register themselves or can delegate this task to other objects and have the chance to alter the state and the event itself for the rest of the callbacks.
Cake Event alternatives and similar libraries
Based on the "Event" category.
Alternatively, view Cake Event alternatives based on common mentions on social networks and blogs.
-
Workerman
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. -
Broadway
Infrastructure and testing helpers for creating CQRS and event sourced applications. -
Evenement
Événement is a very simple event dispatching library for PHP. -
Icicle
Icicle is a PHP library for writing asynchronous code using synchronous coding techniques -
EventSaucePHP
A pragmatic event sourcing library for PHP with a focus on developer experience. -
Novalize for Laravel
Generate Laravel Nova admin panels at light speed with GPT-4. -
Ardillo Event Loop
ReactPHP Event Loop implementation for Ardillo
Clean code begins in your IDE with SonarLint
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Cake Event or a related project?
README
CakePHP Event Library
This library emulates several aspects of how events are triggered and managed in popular JavaScript libraries such as jQuery: An event object is dispatched to all listeners. The event object holds information about the event, and provides the ability to stop event propagation at any point. Listeners can register themselves or can delegate this task to other objects and have the chance to alter the state and the event itself for the rest of the callbacks.
Usage
Listeners need to be registered into a manager and events can then be triggered so that listeners can be informed of the action.
use Cake\Event\Event;
use Cake\Event\EventDispatcherTrait;
class Orders
{
use EventDispatcherTrait;
public function placeOrder($order)
{
$this->doStuff();
$event = new Event('Orders.afterPlace', $this, [
'order' => $order
]);
$this->getEventManager()->dispatch($event);
}
}
$orders = new Orders();
$orders->getEventManager()->on(function ($event) {
// Do something after the order was placed
...
}, 'Orders.afterPlace');
$orders->placeOrder($order);
The above code allows you to easily notify the other parts of the application that an order has been created. You can then do tasks like send email notifications, update stock, log relevant statistics and other tasks in separate objects that focus on those concerns.
Documentation
Please make sure you check the official documentation
*Note that all licence references and agreements mentioned in the Cake Event README section above
are relevant to that project's source code only.