1. Go to this page and download the library: Download cleup/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/ */
use Cleup\Components\Events\Event;
# With the function
Event::add('customEvent', function () {
print_r("Hi, I've been added to the event thread");
});
# Using the function name
function helloWorld () {
print_r('Hello World!');
}
Event::add('customEvent', 'helloWorld');
# Using the class method
Event::add('customEvent', [Example::class, 'get']);
use Cleup\Components\Events\Event;
Event::add('getPosts', function (&$postList) {
// ...
})->position(100);
use Cleup\Components\Events\Event;
Event::add('getPosts', function (&$postList) {
// ...
})->id('isBadPost');
use Cleup\Components\Events\Event;
Event::add('postItem', function ($post) {
// This event will be deleted immediately after execution
})->once();
$posts = array(
0 => [
'id' => 1
'title' => 'First post'
],
1 => [
'id' => 2
'title' => 'Hello world!'
]
)
foreach($posts as $post) {
// The event will be executed only once and will be deleted
Event::apply('postItem', $post);
}
Event::delete('getdPosts');
// Delete event by ID
Event::delete('getdPosts', 'isBadPost');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.