PHP code example of buzzingpixel / php-scheduler

1. Go to this page and download the library: Download buzzingpixel/php-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/ */

    

buzzingpixel / php-scheduler example snippets




declare(strict_types=1);

use App\SomeScheduledClass;
use BuzzingPixel\Scheduler\Frequency;
use BuzzingPixel\Scheduler\ScheduleItem;
use BuzzingPixel\Scheduler\ScheduleItemCollection;

class ScheduleFactory implements \BuzzingPixel\Scheduler\ScheduleFactory
{
    public function createSchedule(): ScheduleItemCollection
    {
        return new ScheduleItemCollection([
            new ScheduleItem(
                Frequency::FIVE_MINUTES,
                SomeScheduledClass::class,
                // Optionally provide a method, otherwise it will default to __invoke
                'myMethod',
                // Optionally send a context array that will be passed as the first argument to your method
                [
                    'foo' => 'bar',
                ],
            ),
        ]);
    }
}

$containerBindings->addBinding(
    \BuzzingPixel\Scheduler\SchedulerTimeZone::class,
    static fn () => new \BuzzingPixel\Scheduler\SchedulerTimeZone(
        new \DateTimeZone('US/Central'),
    ),
);