PHP code example of sparkinzy / laravel-schedule-command

1. Go to this page and download the library: Download sparkinzy/laravel-schedule-command library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sparkinzy / laravel-schedule-command example snippets

 
# 文件 app/Console/Commands/TestCommand.php


namespace App\Console\Commands;

use Illuminate\Console\Scheduling\Schedule;
use Sparkinzy\LaravelScheduleCommand\Commands\ScheduleCommand;

class AdvertAutoDelete extends ScheduleCommand
{
/**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'test:schedule';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '测试命令自带定时任务配置';
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
    
    }

    /**
     * @param Schedule $schedule
     * 此命令每分钟执行一次
     */
    public function schedule(Schedule $schedule)
    {
        #$schedule->command(static::class)
        #            ->everyMinute()
        #            ->runInBackground();
        # 定时任务执行时带参数
        $schedule->command(static::class,['param1'=>'1'])
                            ->everyMinute()
                            ->runInBackground();
    }
}