定制 krydos/php-notifier 二次开发

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

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

krydos/php-notifier

Composer 安装命令:

composer require krydos/php-notifier

包简介

PHP task scheduler

README 文档

README

Build Status

PHPNotifier

PHPNotifier - is a task scheduler. Allows you to schedule a task that will be executed at any time you wish.

Installation

add to your composer.json - "krydos/php-notifier": "*"

Usage

First of all you have to run a script that will be listening for new tasks and execute them when time came.

php ./vendor/bin/phpnotifier /absolute/path/to/db.file

or if you want to leave it working in background

nohup php ./vendor/bin/phpnotifier /absolute/path/to/db.file & >/dev/null 2>&1 &

Using nohup you can see log output in nohup.out file.

How to create new tasks:

use \PHPNotifier\PHPNotifier;

$scheduler = new PHPNotifier(PHPNotifier::FILE_METHOD, '/absolute/path/to/db.file');
$scheduler->scheduleTaskIn(10, 'echo', [
    'Hello world!'
    '>'
    'any_file'
]);  

This task will be executed in 10 seconds. Command that will be executed is echo Hello world! > any_file

Since sometimes you know exact time when you want to run a task and you don't want to calculate how many time is remaining there is another method exists - scheduleTaskAtTime with same signature.

use \PHPNotifier\PHPNotifier;

$scheduler = new PHPNotifier(PHPNotifier::FILE_METHOD, '/absolute/path/to/db.file');
$scheduler->scheduleTaskAtTime(1459382400, 'echo', [
    'Hello world!'
    '>'
    'any_file'
]);  

This method accepts unix timestamp or \DateTime object as first argument. If you use DateTime PHP's object you can get this value by getTimestamp() method.

make sure that binary you're trying to execute is exists in your system

TODO

  • support Redis as task store method
  • support as many store methods as possible
  • ability to accept DateTime as first argument for scheduleTaskAtTime method
  • ability to accept any valid date string as first argument of scheduleTaskAtTime method
  • ability to schedule repeatable tasks

Contributing

There are no special rules. Just send a pull request or create an issue.

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固