定制 valentinmari/cron-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

valentinmari/cron-bundle

最新稳定版本:v0.1

Composer 安装命令:

composer require valentinmari/cron-bundle

包简介

Manage dynamically crons with requests in your PHP site.

关键字:

README 文档

README

  1. Download CronBundle using composer
  2. Enable the Bundle
  3. Define crons in your config

Step 1: Download CronBundle using composer

Add CronBundle by running the command:

$ php composer.phar require valentinmari/cron-bundle "dev-master"

Composer will install the bundle to your project's vendor/valentinmari directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new CronBundle\CronBundle(),
    );
}

Step 3: Define crons in your config

Your site is ready to run crons. Now, write them in the config.yml file. It's recommended put all crons in a new file named cron.yml in your config folder.

#app/config.yml
imports:
    # ...
    - { resource: cron.yml }
#app/cron.yml
cron:
    - { format: '*/1 * * * *', service: test_job }
    - { format: '*/1 * * * *', service: test_job }

The format is like Cron, from Unix. You must define a service, this service must implement JobInterface and redefine the run() method. Inside run() you can put your Job and do anything you want. You can inject things in your service too.

// AppBundle/Services/YourJob.php
namespace AppBundle\Services;
use CronBundle\JobInterface;

class YourJob implements JobInterface{
    public function run(){
        // Do your stuff.
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-05-27