robersonfaria/laravel-database-schedule
最新稳定版本:1.4.0
Composer 安装命令:
composer require robersonfaria/laravel-database-schedule
包简介
Manage your Laravel Task Scheduling in a friendly interface and save schedules to the database.
README 文档
README
Warning
This package is no longer actively maintained. Security vulnerabilities have been reported and will not be patched. Do not use in production. Consider alternatives or fork for your own maintenance.
Documentation
This librarian creates a route(default: /schedule) in your application where it is possible to manage which schedules will be executed at any given moment, these schedules are recorded in the database and can be changed, activated, inactivated or deleted via the interface without the need for a new application deployment.
Installation
- Run
composer require robersonfaria/laravel-database-schedule - Run
php artisan migrate
Environment variables
You can set the following environment variables to configure schedules:
- SCHEDULE_TIMEZONE : The default is the same configured for the application, but if you need the schedules to run in a different timezone, it is possible to configure it with this variable
- SCHEDULE_CACHE_DRIVER : The default is
file - SCHEDULE_CACHE_ENABLE : The default is disabled when
APP_DEBUG=trueand enabled whenAPP_DEBUG=false
Configurations
There are several library configuration options, to change the settings you can get the configuration file for your project
php artisan vendor:publish --provider="RobersonFaria\DatabaseSchedule\DatabaseSchedulingServiceProvider" --tag="config"
Dashboard Authorization
Dashboard Authorization exposes a dashboard at /schedule URI.
In the configuration file it is possible to define whether to restrict access to route /schedule, the default is true. If access is restricted, the user must be logged in and meet the requirements defined in the viewDatabaseSchedule gate controls access.
<?php return [ //... /** * If restricted_access is true, the user must be authenticated and meet the definition of `viewDatabaseSchedule` gate */ 'restricted_access' => env('SCHEDULE_RESTRICTED_ACCESS', true), //... ]
Note that this value can also be changed using the SCHEDULE_RESTRICTED_ACCESS environment variable.
ATTENTION: if restricted_access is set to false, access to the / schedule route will be public.
You must define the gates in your service providers, laravel by default already brings the provider App\Providers\AuthServiceProvider for this purpose. See more in the Laravel documentation https://laravel.com/docs/8.x/authorization#gates
You are free to modify this gate as needed to restrict access to your Database Schedule Dashboard.
protected function gate() { Gate::define('viewDatabaseSchedule', function ($user) { return in_array($user->email, [ 'roberson.faria@gmail.com', ]); }); }
Examples:
If you want to limit access to a route to users who have a certain role, you can do so.
Gate::define('viewDatabaseSchedule', function ($user) { return $user->hasRole('administrator'); });
Basically, if your gate has return true access will be allowed, if return false access will be restricted.
Groups:
If you have a lot of jobs, you can make managing them easier by enabling the groups feature in config/database-schedule.php:
/** * If you have a lot of jobs, you can group them for easier managing of jobs. */ 'enable_groups' => true,
This will allow you to filter in the job listing only the jobs belonging to a certain group.
Scheduled Task Example
Create the command for your scheduled task app/Console/Commands/test.php:
<?php namespace App\Console\Commands; use Illuminate\Console\Command; class test extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'command:test {user} {initialDate} {finalDate}'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $this->info('Hello ' . $this->argument('user')); $this->info("Initial Date: " . $this->argument('initialDate')); $this->info("Final Date: " . $this->argument('finalDate')); return 0; } }
Access the dashboard and the command will be listed for scheduling, create a schedule like the example below:

Run the artisan command to run scheduled tasks
php artisan schedule:run
The console output will look like this
Running scheduled command: ('/usr/bin/php7.4' 'artisan' command:test 1 '2022-02-02 00:00:00' '2022-04-02 00:00:00' > 'path/to/storage/logs/schedule-8763d2ce5a20ee888dd9d8a7e5a5cfcd4b315375.log' 2>&1 ;
If you marked the sending of the output by email you will receive an email similar to this one:
Schedule List
You can also list registered and active commands using artisan command:
$ php artisan schedule:list +----------------------------------------------------------------------------------------+-----------+-------------+----------------------------+ | Command | Interval | Description | Next Due | +----------------------------------------------------------------------------------------+-----------+-------------+----------------------------+ | '/usr/bin/php7.4' 'artisan' inspire | * * * * * | | 2022-03-02 17:05:00 +00:00 | | '/usr/bin/php7.4' 'artisan' command:test 1 '2022-02-02 00:00:00' '2022-04-02 00:00:00' | * * * * * | | 2022-03-02 17:05:00 +00:00 | +----------------------------------------------------------------------------------------+-----------+-------------+----------------------------+
CHANGELOG
Credits
- That library was inspired by the library therezor/laravel-database-schedule
robersonfaria/laravel-database-schedule 适用场景与选型建议
robersonfaria/laravel-database-schedule 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123.03k 次下载、GitHub Stars 达 332, 最近一次更新时间为 2021 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「schedule」 「task」 「laravel」 「jobs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 robersonfaria/laravel-database-schedule 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 robersonfaria/laravel-database-schedule 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 robersonfaria/laravel-database-schedule 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Enables the creation of cron-jobs tasks to be consumed by symfony/messenger
Expose the DDev executable commands to the Robo task runner.
A Deployment/Change Log Schedule and Notes system for SilverStripe sites
Monitoring for scheduled jobs
Task system for APPUI
A Laravel package to manage your cron jobs through a beautiful dashboard (fork with categories and ping urls)
统计信息
- 总下载量: 123.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 333
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-10


