PHP code example of jiordiviera / laravel-smart-scheduler
1. Go to this page and download the library: Download jiordiviera/laravel-smart-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/ */
jiordiviera / laravel-smart-scheduler example snippets
return [
// Days to retain execution records
'purge_days' => 7,
// Minutes before a task is considered stuck
'stuck_timeout_minutes' => 60,
'notifications' => [
'email' => [
'recipients' => ['[email protected]'],
],
'notify_on_stuck' => true,
],
];
use Illuminate\Support\Facades\Schedule;
Schedule::command('backup:run')->daily();
Schedule::command('reports:generate')->hourly();
use Jiordiviera\SmartScheduler\LaravelSmartScheduler\Models\ScheduleRun;
// Get recent executions
$runs = ScheduleRun::latest('started_at')->limit(10)->get();
// Get failed executions
$failed = ScheduleRun::where('status', ScheduleRun::STATUS_FAILED)->get();
// Get stuck executions
$stuck = ScheduleRun::where('status', ScheduleRun::STATUS_STUCK)->get();
use Illuminate\Support\Facades\Schedule;
// Purge old records weekly
Schedule::command('smart-scheduler:purge')->weekly();
// Detect stuck tasks every 30 minutes
Schedule::command('smart-scheduler:detect-stuck')->everyThirtyMinutes();
use Jiordiviera\SmartScheduler\LaravelSmartScheduler\Contracts\SmartNotifierInterface;
use Jiordiviera\SmartScheduler\LaravelSmartScheduler\Models\ScheduleRun;
class SlackNotifier implements SmartNotifierInterface
{
public function sendFailureNotification(ScheduleRun $run): void
{
// Send to Slack
}
public function sendStuckNotification(ScheduleRun $run): void
{
// Send to Slack
}
}