This package for setting commands in schedule.
Require this package with composer using the following command
composer require tkachikov/chronos
Run Chronos command for install:
php artisan chronos:install
Added Chronos scheduler in app/Console/Kernel.php
:
// ...
use Tkachikov\Chronos\Services\ScheduleService;
// ...
class Kernel extends ConsoleKernel
{
// ...
protected function schedule(Schedule $schedule): void
{
app(ScheduleService::class)->schedule($schedule);
}
// ...
}
In defaults pages open for all users and also without auth middleware.
For open setting pages for authenticated users need uncommented 'auth' middleware in config chronos.php
:
return [
'domain' => env('CHRONOS_DOMAIN'),
'middlewares' => [
'web',
'auth',
// 'Tkachikov\Chronos\Http\Middleware\Authorize',
],
];
For authorization in production uncommented Chronos auth in config chronos.php
and set statements in app/Providers/ChronosServiceProvider
:
return [
'domain' => env('CHRONOS_DOMAIN'),
'middlewares' => [
'web',
'auth',
'Tkachikov\Chronos\Http\Middleware\Authorize',
],
];
// ...
class ChronosServiceProvider extends ChronosApplicationServiceProvider
{
// ...
protected function gate(): void
{
Gate::define('viewChronos', function ($user) {
return $user->hasRole('admin');
});
}
}
Visit route /chronos
, example: localhost:8000/chronos
If you need off run command from Chronos dashboard (notRunInManual
) or schedules (notRunInSchedule
) set attributes:
For example all off:
// ...
#[notRunInManual]
#[notRunInSchedule]
class TestCommand extends Command
{
// ...
}
For logging command messages and set status added trait ChronosRunnerTrait
:
// ...
class TestCommand extends Command
{
use ChronosRunnerTrait;
// ...
}
Open your command and set params for it in Create schedule
and save.
For off command click button edit, check to off Run
and save:
For calculate statistics run commands you must create schedule for chronos:update-metrics
This package is open-sourced software licensed under the MIT license.