PHP code example of spatie / laravel-short-schedule
1. Go to this page and download the library: Download spatie/laravel-short-schedule 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/ */
spatie / laravel-short-schedule example snippets
// in your routes/console.php file
use Spatie\ShortSchedule\Facades\ShortSchedule;
// this command will run every second
ShortSchedule::command('artisan-command')->everySecond();
// this command will run every 30 seconds
ShortSchedule::command('another-artisan-command')->everySeconds(30);
// this command will run every half a second
ShortSchedule::command('another-artisan-command')->everySeconds(0.5);
// in app\Console\Kernel.php
protected function shortSchedule(\Spatie\ShortSchedule\ShortSchedule $shortSchedule)
{
// this command will run every second
$shortSchedule->command('artisan-command')->everySecond();
// this command will run every 30 seconds
$shortSchedule->command('another-artisan-command')->everySeconds(30);
// this command will run every half a second
$shortSchedule->command('another-artisan-command')->everySeconds(0.5);
// this command will run every second and its signature will be retrieved from command automatically
$shortSchedule->command(\Spatie\ShortSchedule\Tests\Unit\TestCommand::class)->everySecond();
}
// in your routes/console.php file
use Spatie\ShortSchedule\Facades\ShortSchedule;
ShortSchedule::command('artisan-command')->everySecond();
// in app\Console\Kernel.php
protected function shortSchedule(\Spatie\ShortSchedule\ShortSchedule $shortSchedule)
{
// this artisan command will run every second
$shortSchedule->command('artisan-command')->everySecond();
// this artisan command will run every second, its signature will be resolved from container
$shortSchedule->command(\Spatie\ShortSchedule\Tests\Unit\TestCommand::class)->everySecond();
}