plateau/automaton 问题修复 & 功能扩展

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

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

plateau/automaton

Composer 安装命令:

composer require plateau/automaton

包简介

Task Scheduler for Laravel 4.x

README 文档

README

Latest Stable Version Total Downloads License

Automaton is a task Scheduler for Laravel 4 designed to run as a CronJob. It's designed to run resource intensive tasks with PHP CLI while providing a user friendly way to track down the execution of the tasks.

The planned tasks are stored in a database table, and are 'sandboxed' so any exception occuring will be logged into the database for easier debugging.

Installation

Add this into require-dev in your composer.json file:

"require-dev" : {
	...
	"plateau/automaton": "dev-master"
}

Run an update:

php composer.phar update

Register the console service provider in app/config/app.php:

'providers' => array(
	...
	'Plateau\Automaton\AutomatonServiceProvider',
);

Register the facade :

	'Automaton' => 'Plateau\Automaton\AutomatonFacade',
);

Run migrations

php artisan migrate --package=plateau/automaton

Usage

Configure your crontab to run Automaton at a regular interval :

* * * * * php /var/www/laravel-app/artisan automaton:run >/dev/null 2>&1

Create a task class that contains your logic :

use Plateau\Automaton\AbstractTask;

class MyTask extends AbstractTask {
	
	public function fire()
	{
		// Task logic
	}
}

Schedule your task :

// Parameters are accessible from the task object as $this->parameters
$parameters = array('key' => 'value');

$myTask = new MyTask;
$myTask->init($parameters);

Automaton::schedule($myTask, '2014-02-17 12:00:00');

Alternatively you can pass a Carbon object for setting the date :

Automaton::schedule($myTask, Carbon::now->addHours(2));

Scheduling Cron Jobs

If you need your tasks to be run at regular intervals, you can pass cron expression to the scheduler :

// Run a task every minute
Automaton::cron($myTask, '* * * * *');

Happy Coding!

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固