1. Go to this page and download the library: Download lifetechocms/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/ */
lifetechocms / events example snippets
use Lt\Events\LtEvent;
use Lt\Events\LtListener;
use Lt\Events\LtDispatcher;
//Event Registration
LtEvent::register('userRegistered'); //userRegistered is the eventName
//Listener Registration
//listenerName, ListenerClassPath, and ListenerClassMethod
LtListener::register(
'sendWelcomeEmail',
'App\Listeners\SendWelcomeEmail',
'sendTo'
);
//to allow Event to Listen to a Listener
LtEvent::listen('userRegistered', 'sendWelcomeEmail');
//to Dispatch an Event with a payload, the payload can be array,string or object
LtDispatcher::dispatch('userRegistered', ['email' => '[email protected]']);
use Lt\Events\EventSetting;
EventSetting::set('responseType','json'); //json or array
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.