tkachikov/laravel-pulse

Settings commands for scheduling

2.0.6 2024-02-09 15:52 UTC

This package is auto-updated.

Last update: 2024-04-26 13:36:47 UTC


README

License: MIT

This package for setting commands in schedule.

DEPRECATED! MOVED TO: https://github.com/tkachikov/chronos

Installation

Require this package with composer using the following command

composer require tkachikov/laravel-pulse

Run Laravel pulse command for install:

php artisan pulse:install

Added Laravel pulse scheduler in app/Console/Kernel.php:

// ...
use Tkachikov\LaravelPulse\Services\ScheduleService;

// ...
class Kernel extends ConsoleKernel
{
    // ...
    protected function schedule(Schedule $schedule): void
    {
        app(ScheduleService::class)->schedule($schedule);
    }
    // ...
}

Authorization

For authorization in production set statements in app/Providers/LaravelPulseServiceProvider, example:

// ...
class LaravelPulseServiceProvider extends LaravelPulseApplicationServiceProvider
{
    // ...
    protected function gate(): void
    {
        Gate::define('viewPulse', function ($user) {
            return $user->hasRole('admin');
        });
    }
}

Usage

Visit route /route, example: localhost:8000/pulse

For testing

Open pulse:test command: Open test

Run pulse:test command: Run test

Run attributes

If you need off run command from Laravel Pulse dashboard (notRunInManual) or schedules (notRunInSchedule) set attributes:
For example all off:

// ...
#[notRunInManual]
#[notRunInSchedule]
class TestCommand extends Command
{
    // ...
}

Logging and states

For logging command messages and set status added trait PulseRunnerTrait:

// ...
class TestCommand extends Command
{
    use PulseRunnerTrait;
    // ...
}

Create schedules

Open your command and set params for it in Create schedule and save. Create schedule

For off command click button edit, check to off Run and save: Off schedule

Statistics

For calculate statistics run commands you must create schedule for pulse:update-metrics

License

This package is open-sourced software licensed under the MIT license.