laravel Modules外掛內定時任務執行,自定義命令註冊,外掛內資源釋出

King_JW發表於2020-09-25

找到Modules中模組的Provider資料夾

Laravel

public function boot()
    {
        $this->registerTranslations();
        $this->registerConfig();
        $this->registerViews();
        $this->registerFactories();
        $this->commands([\Modules\GoogleSitemap\Console\GenerateSitemapCommand::class]);//命令註冊
        $this->app->booted(function () {
            $schedule = $this->app->make(Schedule::class);
            $schedule->command('sitemap:generate')->daily();
        });//定時命令啟動
        $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
        $this->publishes([
            __DIR__.'/../Resources/assets/image/' => public_path('images/plugins'),
        ], 'public');//資料夾釋出
    }
本作品採用《CC 協議》,轉載必須註明作者和本文連結
周嘉偉

相關文章