2017 © Pedro Peláez
 

library tactician-scheduler-plugin

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

image

connectholland/tactician-scheduler-plugin

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  • Monday, September 18, 2017
  • by RonRademaker
  • Repository
  • 2 Watchers
  • 18 Stars
  • 3,066 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

tactician-scheduler-plugin

Tactician plugin that allows scheduling a command to be executed at a specific time in the future, (*1)

Build Status Coverage Status SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Concept

This plugin allows you to create ScheduledCommands that will be executed at a specific time in the future., (*3)

Usage

Make sure you put the SchedulerMiddleware in your CommandBus middleware chain:, (*4)

// create your other middleware
$middleware[] = new SchedulerMiddleware(new FileBasedScheduler($pathWhereTheSchedulerMayKeepItsFiles) );
// create your other middleware
$commandbus = new CommandBus($middleware);

Let the command you want to schedule extend from AbstractScheduledCommand or implement the ScheduledCommandInterface. Create it and set a execution time:, (*5)

class SayHappyNewYear extends AbstractScheduledCommand
{
    private $message;

    public function __construct($message)
    {
        $this->message = $message;
    }

    public function getMessage() 
    {
        return $this->message;
    }
}

$myScheduledCommand = new SayHappyNewYear('Happy New Year');
$myScheduledCommand->setTimestamp(strtotime('2016-01-01 0:00:00') );
$myCommandBus->handle($myScheduledCommand);

Create a bootstrap file that builds your Commandbus and cron the schedule execution command, for example bootstrap.php, (*6)

// setup any environment you need
// create your other middleware
$middleware[] = new SchedulerMiddleware(new FileBasedScheduler($pathWhereTheSchedulerMayKeepItsFiles) );
// create your other middleware
$commandbus = new CommandBus($middleware);
return $commandbus;

Cron the scheduler at any interval you like (the more it runs, the better you can time your commands), example for once a minute, (*7)

* * * * *   www-data    vendor/bin/scheduler scheduler:execute bootstrap.php

Or you can use the daemon command that ships with the package, to schedule an iteration every 10 seconds use:, (*8)

vendor/bin/scheduler scheduler:daemon bootstrap.php 10

To make it stop after a minute use:, (*9)

vendor/bin/scheduler scheduler:daemon bootstrap.php 10 6

The Versions

18/09 2017

dev-master

9999999-dev

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker

04/04 2016

1.1.1

1.1.1.0

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker

04/04 2016

dev-stable-tactician

dev-stable-tactician

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker

04/04 2016

dev-revert-8-stateful-command

dev-revert-8-stateful-command

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker

11/11 2015

dev-stateful-command

dev-stateful-command

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker

29/09 2015

1.1.0

1.1.0.0

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker

14/08 2015

1.0.0

1.0.0.0

Tactician plugin that allows scheduling a command to be executed at a specific time in the future

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ron Rademaker