PHP code example of token27 / cakephp-scheduled-plugin

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

    

token27 / cakephp-scheduled-plugin example snippets


// path-to-project/src/ScheduledTasks/ScheduledBackupTask.php

use Scheduled\Scheduled\Scheduled;
$schedule = new \Scheduled\Scheduled\Scheduled();
$scheduled
    ->run('/usr/bin/php backup.php')
    ->daily()
    ->description('Test');

// IMPORTANT: You must return the scheduled object
return $scheduled;

use Scheduled\Scheduled\Scheduled;
$schedule = new \Scheduled\Scheduled\Scheduled();

$scheduled
    ->run('/usr/bin/php backup.php')
    ->before(function() { 
        // Do something before the job runs
     })
    ->daily()
    ->description('Test');

// IMPORTANT: You must return the scheduled object
return $scheduled;

use Scheduled\Scheduled\Scheduled;
$schedule = new \Scheduled\Scheduled\Scheduled();

$scheduled
    ->run('/usr/bin/php backup.php')
    ->after(function() { 
        // Do something after the job is finished
     })
    ->daily()
    ->description('Test');
	
// IMPORTANT: You must return the scheduled object
return $scheduled;
$scheduled->run('/usr/bin/php backup.php')