PHP code example of mvaliolahi / scheduler

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

    

mvaliolahi / scheduler example snippets


    
    $scheduler = new Scheduler([
        'cwd' => 'project path | where commands can be run',
        'command_prefix' => 'php specific-cli',
        'cache' => 'an implementation from OverlappinCache Contract'
    ]);
        
    $scheduler->command('rm test.php -fr')
    ->hourly()
    ->when(function()
    {
        return true; // in this situation.
    });
        
        
        $scheduler->start();

   ->everyMinute();	Run the command every minute
   ->everyFiveMinutes();	Run the command every five minutes
   ->everyTenMinutes();	Run the command every ten minutes
   ->everyFifteenMinutes();	Run the command every fifteen minutes
   ->everyThirtyMinutes();	Run the command every thirty minutes
   ->hourly();	Run the command every hour
   ->hourlyAt(17);	Run the command every hour at 17 mins past the hour
   ->daily();	Run the command every day at midnight
   ->dailyAt('13:00');	Run the command every day at 13:00
   ->twiceDaily(1, 13);	Run the command daily at 1:00 & 13:00
   ->weekly();	Run the command every week
   ->monthly();	Run the command every month
   ->monthlyOn(4, '15:00');	Run the command every month on the 4th at 15:00
   ->quarterly();	Run the command every quarter
   ->yearly();	Run the command every year
   ->timezone('America/New_York');	Set the timezone
   ->weekdays();	Limit the command to weekdays
   ->sundays();	Limit the command to Sunday
   ->mondays();	Limit the command to Monday
   ->tuesdays();	Limit the command to Tuesday
   ->wednesdays();	Limit the command to Wednesday
   ->thursdays();	Limit the command to Thursday
   ->fridays();	Limit the command to Friday
   ->saturdays();	Limit the command to Saturday
   ->between($start, $end);	Limit the command to run between start and end times
   ->when(Closure);	Limit the command based on a truth test