PHP code example of brzuchal / scheduler
1. Go to this page and download the library: Download brzuchal/scheduler 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/ */
brzuchal / scheduler example snippets
use Brzuchal\Scheduler\Executor\SimpleScheduleExecutor;
use Brzuchal\Scheduler\MessageScheduler;
use Brzuchal\Scheduler\Store\PdoScheduleStore;
$store = new PdoScheduleStore(new PDO('sqlite:scheduler.sqlite'));
$scheduler = new MessageScheduler($store);
$executor = new SimpleScheduleExecutor($store, var_dump(...));
// Scheduling message
$scheduler->schedule(new DateTimeImmutable('tomorrow 09:00:00'), new \FooMessage());
// Execute all pending messages
$dateTime = new DateTimeImmutable('now');
foreach ($store->findPendingSchedules($dateTime) as $identifier) {
$executor->execute($identifier);
}