babacooll/command-planner

Command cron planner

v0.0.1 2015-04-28 17:53 UTC

This package is auto-updated.

Last update: 2024-12-12 04:29:43 UTC


README

SensioLabsInsight Scrutinizer Code Quality Code Coverage Build Status

CommandPlanner is a cron management for Symfony Console component commands.

Installation

CommandPlanner is available through composer :

$ php composer.phar require babacooll/command-planner ~0.0.1

Usage

You can load method in CommandPlanner by two ways :

Example inline

PHP File :

<?php

require('vendor/autoload.php');

use CommandPlanner\CommandPlanner;

$commandPlanner = new CommandPlanner();

$commandPlanner->add(
    new \CommandPlanner\Wrapper\CommandWrapper(
        'CommandPlanner\Tests\Data\TestCommand',
        'Symfony\Component\Console\Application',
        \Cron\CronExpression::factory('* * * * *'),
        [
            'parameters' => ['test'],
            'log_file'   => 'test.log',
            'options'    => []
        ]
    )
);

$commandPlanner->run();

Example from config

PHP File :

<?php

require('vendor/autoload.php');

use CommandPlanner\CommandPlanner;

$commandPlanner = new CommandPlanner();

$commandPlanner->addCommandsFromConfig('config/config.yml');

$commandPlanner->run();

Config File :

command_planner:
    commands:
        my_first_command:
            namespace : CommandPlanner\Tests\Data\TestCommand
            timing: '* * * * * *'
            parameters: ['test']
            options: ['--yell']
            log_file: test.log

    application: Symfony\Component\Console\Application

These examples use CommandPlanner\Tests\Data\TestCommand test command from this package.

TODO

  • Unit testing
  • Exception handler