composer require qklin/laravel-kernel-plus
'providers' => [ ... Qklin\Kernel\Plus\KernelPlusProvider::class, ]
# 會加載註冊全部的comand命令腳本,並自動加入schedule隊列, 無需手動個添加 php artisan schedule:run # 自動註冊command,並執行 php artisan c:cmd:core:test
command::handle()php
// * @command true //註冊command // * @commandParams param1=foo&--option=1 //本參數可省略 // * @schedule true //加入schedule // * @runTime everyMinute //無參數的全部方法都支持 // * @runTime cron|* * * * * // 目前只支持cron帶參數,方法和參數[|]分隔 // * @withoutOverlapping true // * @runInBackground true // * @appendOutputTo test/log //記錄日誌,位置:storage目錄 // * @deprecated
默認的env配置laravel
KERNEL_PLUS_ORIGIN_PREFIX=c KERNEL_PLUS_MODULE_PREFIX=cm KERNEL_PLUS_MODULE_DIR=Biz KERNEL_PLUS_COMMANDS_DIR=cmd KERNEL_DOCMENT_CMD=command KERNEL_DOCMENT_CMD_PARAM=commandParams KERNEL_DOCMENT_SCHEDULE=schedule KERNEL_DOCMENT_RUN_TIME=runTime KERNEL_DOCMENT_RUN)BACKGROUND=runInBackground KERNEL_DOCMENT_LOG=appendOutputTo KERNEL_DOCMENT_OVER_LAPPING=withoutOverlapping KERNEL_DOCMENT_DEPRACATED=deprecated
<?php namespace App\Console\Commands\Core; use App\Console\BaseCommand; class Test extends BaseCommand { // 依賴關係 // 自動解決依賴,適用於單腳本依賴,不適用http const DEPENDS = [ Testdepend::class ]; // 腳本命令註冊名 const COMMAND_SIGN = 'c:cmd:core:test'; protected $signature = self::COMMAND_SIGN . ' {param1?}'; protected $description = '自動注入腳本測試'; /** * @command true * @schedule true * @runTime everyMinute * @runTime cron|* 1 * * * * @withoutOverlapping true * @runInBackground true * @appendOutputTo logs/c_core_test */ public function handle() { $this->info("test finish"); } }