2017 © Pedro Peláez
 

library silex-cli

A console provider for the Silex micro-framework

image

rmlasseter/silex-cli

A console provider for the Silex micro-framework

  • Friday, January 31, 2014
  • by rmlasseter
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SilexCLI

Services

console

An instance of SilexCLI\Console (which extends Symfony\Component\Console\Application)., (*1)

console.input

An instance of Symfony\Component\Console\Input\ArgvInput, accessible to command callbacks., (*2)

console.output

An instance of Symfony\Component\Console\Output\ConsoleOutput, accessible to command callbacks., (*3)

console.status

Contains the exit code of the last console execution., (*4)

Registering

    use SilexCLI\Provider\ConsoleServiceProvider;

    $app->register(new ConsoleServiceProvider());

Usage

Commands can be registered with the console's route method. The route pattern is used to identify arguments, and dependency injection is used to identify argument defaults and options., (*5)

If a callback parameter is present in the route pattern, it is defined as an argument. Parameters not present in the route pattern are, (*6)

Command Arguments

If a callback parameter is present in the route pattern, it is defined as an argument. If it has a default value, then it will not be required by the console., (*7)

    $app['console']->match('example {arg1}', function($arg1) use ($app) {
        ...
    });

Command Options

Callback parameters not present in the route pattern will be added to the command definition as options. All options must have a default value., (*8)

    $app['console']->match('example', function($opt1 = 'default') use ($app) {
        ...
    });

If the option default is a boolean value, it will be treated as a flag., (*9)

    $app['console']->match('example', function($flag1 = false) use ($app) {
        ...
    });

Array Inputs

Arguments and options can accept array values as well (though only the last argument may be an array)., (*10)

    $app['console']->match('example {array-arg}', function(array $array_arg, array $array_opt = array()) use ($app) {
        ...
    });

Traits

SilexCLI\Application\ConsoleTrait adds the following shortcuts:, (*11)

command

Adds a new command to the console and returns it., (*12)

    $app->command($pattern, $callback);

The Versions

31/01 2014

dev-master

9999999-dev

A console provider for the Silex micro-framework

  Sources   Download

MIT

The Requires

 

console silex cli