aequasi/cron-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aequasi/cron-bundle

最新稳定版本:1.0.1

Composer 安装命令:

composer require aequasi/cron-bundle

包简介

This bundle provides scheduled execution of Symfony2 commands, base on colourstream/cron-bundle

README 文档

README

This bundle provides a simple interface for registering repeated scheduled tasks within your application.

This bundle is tested only against Symfony 2.3, but should work on anything after 2.3, until at least 3.0.

Installation

  1. Add the bundle to your project as a composer dependency:
$ composer require aequasi/cron-bundle "~1.0.0"
  1. Add the bundle to AppKernel:
// AppKernel.php
public function registerBundles()
{
	// ...
	$bundles = array(
		// ...
        new Aequasi\Bundle\CronBundle\AequasiCronBundle(),
	);
    // ...

    return $bundles;
}
  1. Start using the bundle:
$ app/console cron:scan
$ app/console cron:run

Running your cron jobs automatically

This bundle is designed around the idea that your tasks will be run with a minimum interval - the tasks will be run no more frequently than you schedule them, but they can only run when you trigger then (by running app/console cron:run, or the forthcoming web endpoint, for use with webcron services).

To facilitate this, you can create a cron job on your system like this:

*/5 * * * * /path/to/symfony/install/app/console cron:run

This will schedule your tasks to run at most every 5 minutes - for instance, tasks which are scheduled to run every 3 minutes will only run every 5 minutes.

Creating your own tasks

Creating your own tasks with CronBundle couldn't be easier - all you have to do is create a normal Symfony2 Command (or ContainerAwareCommand) and tag it with the @CronJob annotation, as demonstrated below:

/**
 * @CronJob("PT1H")
 */
class DemoCommand extends Command
{
    // ...
}

The interval spec ("PT1H" in the above example) is documented on the DateInterval documentation page, and can be modified whenever you choose. For your CronJob to be scanned and included in future runs, you must first run app/console cron:scan - it will be scheduled to run the next time you run app/console cron:run

If you add a new command, you have to run the scan function for it to get picked up, or clear the symfony cache.

统计信息

  • 总下载量: 85
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固