This package allows you to configure the scheduled tasks of the app via (database) model. It was developed to avoid handling theseconfigurations via a config file only, cause then we cannot share the same repo to n server instances when running different tasks is needed at each server.
diontech/laravel-extended-scheduler is a Laravel package for this package allows you to configure the scheduled tasks of the app via (database) model. it was developed to avoid handling theseconfigurations via a config file only, cause then we cannot share the same repo to n server instances when running different tasks is needed at each server..
It currently has 1 GitHub stars and 1.846 downloads on Packagist (latest version v1.3.0).
Install it with composer require diontech/laravel-extended-scheduler.
Discover more Laravel packages by diontech
or browse all Laravel packages to compare alternatives.
Last updated
This package allows you to configure the scheduled tasks of the app via (database) model. It was developed to avoid handling these configurations via a config file only, cause then we cannot share the same repo to n server instances when running different tasks is needed at each server.
This package will extend the laravel scheduler, so all coded scheduled tasks will still be available.
composer require diontech/laravel-extended-scheduler
php artisan migrate
Instead of used model based handling mentioned below, you can also do Facade based handling, like:
\DionTech\Scheduler\Support\Facades\ScheduledCommand\ScheduledCommand::arguments([
'foo'
])->fluent([
'cron' => [
'* * * * *'
]
])->isActive()
->create();
At the moment you can do something similar to the following:
\DionTech\Scheduler\Models\ScheduledCommand::create([
'method' => 'command',
'arguments' => [
'schedule:list'
],
'fluent' => [
'cron' => ['* * * * *']
],
'is_active' => true
]);
\DionTech\Scheduler\Models\ScheduledCommand::create([
'method' => 'command',
'arguments' => [
'foo'
],
'fluent' => [
'weekdays',
'hourly',
'timezone' => ['America/Chicago'],
'between' => ['8:00', '17:00']
],
'is_active' => true
]);
\DionTech\Scheduler\Models\ScheduledCommand::create([
'method' => 'command',
'arguments' => [
'test:command',
['Taylor', '--force']
],
'fluent' => [
'daily'
],
'is_active' => true
]);
\DionTech\Scheduler\Models\ScheduledCommand::create([
'method' => 'job',
'arguments' => [
'new \App\Jobs\TestJob', 'sqs'
],
'fluent' => [
'everyFiveMinutes'
],
'is_active' => true
]);
See https://laravel.com/docs/8.x/scheduling to get an idea of how it can be used.
$model = \DionTech\Scheduler\Models\ScheduledCommand::create([
'method' => 'command',
'arguments' => [
'foo'
],
'fluent' => [
'weekdays',
'hourly',
'timezone' => ['America/Chicago'],
'between' => ['8:00', '17:00']
],
'is_active' => true
]);
$event = $model->event(); //returns \Illuminate\Console\Scheduling\Event
$command = $event->command; //something like "/usr/local/Cellar/[email protected]/7.4.16/bin/php' 'artisan' foo"
$expression = $event->expression; //something like "0 * * * 1-5"
$description = $event->description; //something like "new \App\Jobs\TestJob"
Each ScheduledCommand can be set to inactive / active by its property 'is_active'. the default value is false, so you must explicitly activate the command to be recognized in the laravel scheduler.
Each ScheduledCommand have a property 'description', where you can save additional notices if needed.
$commands = (new \DionTech\Scheduler\Support\Helper\CommandLister)->all();
insert this in your controller, that's it:
return (new \DionTech\Scheduler\Http\Responses\ListAllCommandsResponse())
->toResponse($request);