PHP code example of codemonster-ru / events

1. Go to this page and download the library: Download codemonster-ru/events library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codemonster-ru / events example snippets


use Codemonster\Events\EventDispatcher;
use Codemonster\Events\ListenerProvider;

$listeners = new ListenerProvider();
$dispatcher = new EventDispatcher($listeners);

$listeners->listen(UserRegistered::class, function (UserRegistered $event): void {
    // Send a welcome email, write an audit log, or trigger domain work.
});

$dispatcher->dispatch(new UserRegistered());