2017 © Pedro Peláez
 

library php-notifier

PHP task scheduler

image

krydos/php-notifier

PHP task scheduler

  • Tuesday, April 5, 2016
  • by KryDos
  • Repository
  • 3 Watchers
  • 11 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 24 % Grown

The README.md

Build Status, (*1)

PHPNotifier

PHPNotifier - is a task scheduler. Allows you to schedule a task that will be executed at any time you wish., (*2)

Installation

add to your composer.json - "krydos/php-notifier": "*", (*3)

Usage

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

php ./vendor/bin/phpnotifier /absolute/path/to/db.file, (*5)

or if you want to leave it working in background, (*6)

nohup php ./vendor/bin/phpnotifier /absolute/path/to/db.file & >/dev/null 2>&1 &, (*7)

Using nohup you can see log output in nohup.out file., (*8)

How to create new tasks:, (*9)

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, (*10)

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., (*11)

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., (*12)

make sure that binary you're trying to execute is exists in your system, (*13)

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., (*14)

The Versions

05/04 2016

dev-master

9999999-dev

PHP task scheduler

  Sources   Download

MIT

The Development Requires

27/03 2016

0.2.0

0.2.0.0

PHP task scheduler

  Sources   Download

MIT

The Development Requires

26/03 2016

0.1.0

0.1.0.0

PHP task scheduler

  Sources   Download

MIT

The Development Requires