承接 matviib/scheduler 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

matviib/scheduler

Composer 安装命令:

composer require matviib/scheduler

包简介

Service for scheduling and managing cron tasks in laravel application

README 文档

README

build passed StyleCI Total Downloads License

Installation

First steps

Add Provider for Laravel < 5.5

MatviiB\Scheduler\SchedulerServiceProvider::class,

Publish config and CronTasksList class files:

php artisan vendor:publish

and choose "Provider: MatviiB\Scheduler\SchedulerServiceProvider" if requested.

Files that must be published:

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

Create database table:

 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
 
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:

<?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

php artisan scheduler:show

And you will see something like this

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.

Note: every scheduler:create execution will soft delete old tasks and create fresh commands data.

php artisan scheduler:create

To use Scheduler you need enable it by adding to your .env next line:

SCHEDULER_ENABLED=true

Let's check status and scheduled tasks:

php artisan scheduler:show

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 |
+-----------------+------------------------------+-----------+-------------+-----+----------+

Usage

You can manage your scheduled task on page /scheduler by default.

Also you are free to configure it yourself in config/scheduler.php.

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.

  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

This is how the creating task page looks like: laravel scheduler

  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

License

Scheduler for Laravel is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 3.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 2
  • Forks: 5
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固