app-zap/phpframework-scheduler
Composer 安装命令:
composer require app-zap/phpframework-scheduler
包简介
README 文档
README
This package is a plugin for PHPFramework.
When writing applications you often want to schedule tasks for later or for regular execution. Instead of configuring a cronjob for each task, you can use the scheduler as a proxy.
Installation
Include this package as requirement in your composer.json. For example:
{
...
"require": {
...
"app-zap/phpframework-scheduler": "dev-develop"
}
}
This plugin requires a certain SQL structure. You have to include it yourself, because PHPFramework isn't capable to load plugin SQL yet:
CREATE TABLE `schedulertask` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`classname` varchar(255) NOT NULL DEFAULT '',
`last_execution` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `classname` (`classname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Hint: If you're using the PHPFramework's database migrator, copy the above statement to a .sql file to have it applied automatically when needed.
Setup a cronjob like this:
*/5 * * * * php path/to/your/projects/index.php invokeScheduler
Configuration
You can set up tasks in your settings.ini:
[phpframework-scheduler]
tasks.MyVendor\MyApp\Task\DailyStatisticsMail = "0 18 * * *"
This calls the DailyStatisticsMail class daily at 6pm. The class has to implement the
\AppZap\PHPFrameworkScheduler\TaskExecutorInterface, which means it has to implement the execute()
method.
For debugging purposes you can enable to start the scheduler via GET request from your browser:
[phpframework-scheduler]
enable_get_request = true
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-01-16