PHP code example of lingoda / cron-bundle

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

    

lingoda / cron-bundle example snippets


class MyCronJob extends ScheduleBaseCronJob
{
    protected function getSchedule(): Schedule
    {
        // this job will execute every hour at the 30th minute
        return Schedule::everyHour(30);
    }

    public function run(): void
    {
        // do the job here
    }
}

class MyCronJob implements CronJobInterface
{
    public function run(): void
    {
        // do the job
    }

    public function shouldRun(DateTimeInterface $lastFinishTime = null): bool
    {
        // implement your own logic for determining if a job should
        // at a particular time or not
    }

    public function getLockTTL(): float
    {
        // before running, an expiring lock is acquired for each job to prevent
        // a job of the same type to run at the same time; with this method
        // the job can specify a custom expiry period in seconds for the lock

        return 30.0;
    }
    
    public function __toString(): string
    {
        // Here comes the cron expression as string, e.g. 30 1 * * *
        return '30 1 * * *';
    }
}