PHP code example of cyub / laravel-task-scheduler

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

    

cyub / laravel-task-scheduler example snippets


'providers' => [
    ...
    Tink\Scheduler\SchedulerServiceProvider::class,
    ...
];


php artisan scheduler:install

return [
    'enable' => true,
    'schedule_table_name' => 'cron_schedule',
    'schedule_generate_every' => 1,
    'schedule_ahead_for' => 50,
    'schedule_lifetime' => 15,
    'history_cleanup_every' => 10,
    'history_success_lifetime' => 600,
    'history_failure_lifetime' => 600,

    'schedules' => [
        'RegisterRedpacket.activate' => [
            'schedule'  => [
                'cron_expr'   => '*/1 * * * *',
            ],
            'run'   => [
                'class' => App\Cron\RegisterRedpacket::class,
                'function'  => 'activate',
                'params'    => ['isSendSmsNotice' => true]
            ],
            'description' => 'activate register redpacket'
        ]
    ]
];
shell
php artisan scheduler:dispatch
shell
* * * * * php /your-application-path/artisan scheduler:dispatch >> /dev/null 2>&1
shell
php artisan scheduler:info stats
shell
php artisan scheduler:clean