eventScheduler
, (*1)
A simple event scheduler application for PHP projects., (*2)
Installation
The Package is available on Packagist,
you can install it using Composer., (*3)
composer require daltonmenezes/eventscheduler
Dependencies
How it works?
Setting a start and finish date, you can trigger different events for each., (*4)
The behavior you set to be triggered on the start date is defined by after() event;, (*5)
The behavior you set to be triggered while the start date is not reached is the before() event;, (*6)
When the finish date is reached, after() event is suspended, as well before() event too., (*7)
The finish date is optional, if you want the after() event continues in your project execution without date limitations, simply do not set the key "finish" in your array., (*8)
Usage
Instantiate EventScheduler\EventScheduler., (*9)
use EventScheduler\EventScheduler;
$event = new EventScheduler();
Define a start date in your schedule, its must be an array., (*10)
$schedule = array("start" => "18-03-2016 23:43");
The start key is for when your event must be triggered. If you want define a finish date for shutdown it, you must define a finish key in your array., (*11)
$schedule = array(
"start" => "18-03-2016 23:43",
"finish" => "20-03-2020 19:13"
);
Now, call the schedule method for set your array., (*12)
$event->schedule($schedule);
Call the before() method for set this behavior. The parameter must be a Closure.
If you do not want call and define this method, it's ok. It's optional., (*13)
$event->before(function() {
// define here whatever you want execute as an expected behavior
});
Call the after() method for set this behavior. The parameter must be a Closure.
If you do not want call and define this method, it's ok. It's optional., (*14)
$event->after(function() {
// define here whatever you want execute as an expected behavior
});
Call the run() method for when all is done!, (*15)
$event->run();
Nothing more! It's simple! ;)
You can read or test the example.php file at the root directory of this project., (*16)
Problems or suggestions?
Open a Issue. :), (*17)