2017 © Pedro Peláez
 

library scheduler

Service for scheduling and managing cron tasks in laravel application

image

matviib/scheduler

Service for scheduling and managing cron tasks in laravel application

  • Wednesday, July 4, 2018
  • by MatviiB
  • Repository
  • 2 Watchers
  • 4 Stars
  • 22 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 57 % Grown

The README.md

build passed StyleCI Total Downloads License, (*1)

Installation

First steps

Add Provider for Laravel < 5.5, (*2)

MatviiB\Scheduler\SchedulerServiceProvider::class,

Publish config and CronTasksList class files:, (*3)

php artisan vendor:publish

and choose "Provider: MatviiB\Scheduler\SchedulerServiceProvider" if requested., (*4)

Files that must be published:, (*5)

config/scheduler.php
app/Console/CronTasksList.php

Create database table:, (*6)

 php artisan migrate
 ```
## Let's finish setup

###### Move your commands from `App\Console\Kernel` schedule() function to new file: `CronTasksList.php` trait.

Add next line to schedule() function instead of list of commands:

```php
<?php

namespace App\Console;

use MatviiB\Scheduler\Console\Kernel as SchedulerKernel;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        ..
        ..
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // make changes just here
        // cut your commands from here
        // and write next line
        with(new SchedulerKernel())->schedule($schedule);
    }

Paste your commands to app/Console/CronTasksList.php trait:, (*7)

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;

/**
 * Trait CronTasksList
 *
 * To use: uncomment all lines and copy your commands list
 * from app/Console/Kernel.php schedule() to tasks() function.
 *
 * @package App\Console
 */
trait CronTasksList
{
    public function tasks(Schedule $schedule)
    {
        // paste your commands here
        $schedule->command('example:command')->yearly()->withoutOverlapping();
    }
}

If everything done for now you can run next command, it will show your current commands list, (*8)

php artisan scheduler:show

And you will see something like this, (*9)

Scheduler is disabled.
You see standard tasks list.
+-----------------+------------------------------+-----------+-------------+-----+----------+
| command         | description                  | is_active | expression  | w_o | interval |
+-----------------+------------------------------+-----------+-------------+-----+----------+
| command:name    | Description for command:name | 1         | 0 * * * * * | 1   | 1 hour   |
| example:command | Command description          | 1         | * * * * * * | 1   | 1 minute |
+-----------------+------------------------------+-----------+-------------+-----+----------+

To use Scheduler you need to copy commands to schedulers table., (*10)

Note: every scheduler:create execution will soft delete old tasks and create fresh commands data., (*11)

php artisan scheduler:create

To use Scheduler you need enable it by adding to your .env next line: ```sh SCHEDULER_ENABLED=true, (*12)


Let's check status and scheduled tasks:

php artisan scheduler:show, (*13)


And you will see something like this:

Scheduler is enabled. You see scheduled tasks list configured with Scheduler. +-----------------+------------------------------+-----------+-------------+-----+----------+ | command | description | is_active | expression | w_o | interval | +-----------------+------------------------------+-----------+-------------+-----+----------+ | command:name | Description for command:name | 1 | 0 * * * * * | 1 | 1 hour | | example:command | Command description | 1 | * * * * * * | 1 | 1 minute | +-----------------+------------------------------+-----------+-------------+-----+----------+ ```, (*14)

Usage

You can manage your scheduled task on page /scheduler by default., (*15)

Also you are free to configure it yourself in config/scheduler.php., (*16)

After creating operation you will have your scheduled tasks list and it will ready to work but with scheduler you have some more powerfull things., (*17)

  1. You can create different tasks for same command with different parameters and run it separately.

On the next screenshot you can see the same scheduled task for generate report with argument user equal 1 and option --client=2 for first task and argument user equal 3 and option --client=4 for next one. laravel scheduler, (*18)

This is how the creating task page looks like: laravel scheduler, (*19)

  1. Next powerfull thing - You can run your tasks from UI imediately with different arguments and options.

Next screenshot shows how it works: laravel scheduler, (*20)

License

Scheduler for Laravel is open-sourced software licensed under the MIT license., (*21)

The Versions

04/07 2018

dev-master

9999999-dev

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

04/07 2018

dev-analysis-qg32PQ

dev-analysis-qg32PQ

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

04/07 2018

dev-develop

dev-develop

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

24/02 2018

v1.0.1

1.0.1.0

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

24/02 2018

dev-analysis-8bB7ol

dev-analysis-8bB7ol

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

24/02 2018

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

15/02 2018

v1.0.0

1.0.0.0

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

15/02 2018

v0.2.1

0.2.1.0

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

29/01 2018

v0.1.1

0.1.1.0

Service for scheduling and managing cron tasks in laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

25/01 2018

v0.0.2

0.0.2.0

Scheduler service for laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks

25/01 2018

v0.0.1

0.0.1.0

Scheduler service for laravel application

  Sources   Download

MIT

by Matvii Bondar

laravel scheduler schedule cron tasks