laravel Modules插件内定时任务执行,自定义命令注册,插件内资源发布

找到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');//文件夹发布
    }

posted on 2021-07-21 18:03  KingJW  阅读(99)  评论(0)    收藏  举报

导航