syrotchukandrew/chain-command-bundle

Symfony bundle that implements command chaining functionality.

dev-master 2016-11-08 13:54 UTC

This package is not auto-updated.

Last update: 2024-05-11 18:07:19 UTC


README

ChainCommandBundle help you run your commands as chain of commands. You have opportunity to register console

commands from Symfony bundles as members of command chain. You define main command and append other command

as children with some priority. You can create one or several chains. When main command in chain is running

every command in chain will be accomplished in order your priority.

Installation

###Step 1: Download the Bundle

Open a terminal, change directory to your project directory and run the following command to download the this bundle:

$ composer require syrotchukandrew/chain-command-bundle

or add to your composer.json file following:

"require" : {
        "syrotchukandrew/chain-command-bundle" : "dev-master"        
    },    
"repositories" : [{
        "type" : "vcs",        
        "url" : "https://github.com/syrotchukandrew/ChainCommandBundle.git"        
    }],

and run command:

$ composer update

###Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new ChainCommandBundle\ChainCommandBundle(),
        );

        // ...
    }

    // ...
}

How to use

For adding command in chain of commands you should register command

as service with tag "chain_command" - after that command is member of chain.

Additional information as 'parent'='main' define your service as main command:

    tags:
        - { name: chain_command, parent: main, priority:  null}

or 'parent'='main_command_name' define your command as member of chain where

main command's name is 'main_command_name':

    tags:
        - { name: chain_command, parent: main_command_name, priority:  10}

priority define order executing commands in chain.