dedermus / scheduling
Laravel open-admin-core 的任务调度扩展
2.0.1
2024-09-09 09:29 UTC
Requires
- php: ^8.2
- dedermus/open-admin-core: ^v2.0
Requires (Dev)
- laravel/laravel: ~5.5
- phpunit/phpunit: ~6.0
This package is not auto-updated.
Last update: 2024-09-23 09:42:09 UTC
README
用于管理 Laravel 中任务调度的网络界面。
截图
安装
$ composer require dedermus/scheduling
$ php artisan admin:import scheduling
进入终端: php artisan make:provider ScheduleCommandProvider
打开 app/Providers/ScheduleCommandProvider.php
。
添加方法 registerScheduledCommands()
/** * Register scheduled commands from routes/console.php. * * @return void */ protected function registerScheduledCommands() { app()->make('Illuminate\Contracts\Console\Kernel'); $events = app()->make('Illuminate\Console\Scheduling\Schedule'); // Load the routes/console.php file $consoleRoutes = base_path('/routes/console.php'); if (File::exists($consoleRoutes)) { require $consoleRoutes; } }
添加修改方法 boot()
$this->registerScheduledCommands();
打开文件 bootstrap/providers.php
并添加提供者
App\Providers\ScheduleCommandProvider::class,
打开 http://your-host/admin/scheduling
。
尝试在 routes/console.php
中添加调度任务,例如
Schedule::command('inspire')->everyTenMinutes()->runInBackground(); Schedule::command('route:list')->dailyAt('02:00');
添加 use use Illuminate\Support\Facades\Schedule;
您可以在调度面板中找到这些任务。
调试
如果控制台显示错误: sh: : 命令未找到
尝试在您的 .env 文件中添加此行: PHP_BINARY=/path/to/your/php/binaray/
许可
根据 MIT 许可证 (MIT) 许可。