2017 © Pedro Peláez
 

library zf2-cli

helper functions for building a zf2 CLI app

image

heartsentwined/zf2-cli

helper functions for building a zf2 CLI app

  • Wednesday, July 6, 2016
  • by heartsentwined
  • Repository
  • 1 Watchers
  • 1 Stars
  • 241 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

zf2-cli

Build Status, (*1)

helper functions for building a zf2 CLI app, (*2)

Installation

Composer:, (*3)

{
  "require": {
    "yalesov/zf2-cli": "2.*"
  }
}

Copy config/cli.local.php.dist into (app root)/config/autoload/cli.local.php, and edit configs as described below in Setup templates., (*4)

Usage

Get an instance of cli

Use service locator., (*5)

$cli = $locator->get('cli');
$cli = $locator->get('Yalesov\Cli\Cli');

Or just instantiate one manually., (*6)

$cli = new \Yalesov\Cli\Cli;

Templated-text

Often you need to display similarly-formatted text in a CLI app, e.g. section titles., (*7)

Setup templates

Add a template named section, which outputs a blue string ## %s ## (%s replaced by actual text)., (*8)

$cli->addTemplate('section', array(
  'template' => '## %s ##',
  'color'    => 'BLUE',
));
  • template: (optional), %s as text placeholder; not set = '%s' (plain text)
  • color: (optional), a \Zend\Console\ColorInterface defined constant name; not set = default / normal color

You can also inject templates through the config file:, (*9)

return array(
  'di' => array(
    'instance' => array(
      'alias' => array(
        'cli' => 'Yalesov\Cli\Cli',
      ),
      'cli' => array(
        'parameters' => array(
          'templates' => array (
            'section' => array(
              'template' => '## %s ##',
              'color'    => 'YELLOW',
            ),
            'task' => array (
              'template' => '- %s -',
              'color'    => 'BLUE',
            ),
            'module' => array(
              'template' => '[ %s ]',
              'color'    => 'GREEN',
            ),
          ),
        ),
      ),
    ),
  ),
);

This will setup the templates section, task, and module., (*10)

Output text

$cli->write('foo', 'section');

This will output the string foo using the section template. In the above example setup, this will output ## foo ##, with yellow color., (*11)

You can also capture the output string instead of printing it directly:, (*12)

$string = $cli->write('foo', 'section', false);

The Versions

06/07 2016

dev-master

9999999-dev https://github.com/yalesov/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

helper zf2 cli

06/07 2016

v2.1.3

2.1.3.0 https://github.com/yalesov/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

helper zf2 cli

06/07 2016

v2.1.2

2.1.2.0 https://github.com/yalesov/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

helper zf2 cli

06/07 2016

v2.1.1

2.1.1.0 https://github.com/yalesov/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

helper zf2 cli

05/07 2016

v2.1.0

2.1.0.0 https://github.com/yalesov/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

ISC

The Requires

 

by Yulij Andreevich Lesov

helper zf2 cli

05/07 2016

v2.0.0

2.0.0.0 https://github.com/yalesov/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

ISC

The Requires

 

by Yulij Andreevich Lesov

helper zf2 cli

03/10 2012

1.0.3

1.0.3.0 https://github.com/heartsentwined/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

helper zf2 cli

28/09 2012

1.0.2

1.0.2.0 https://github.com/heartsentwined/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

helper zf2 cli

18/09 2012

1.0.1

1.0.1.0 https://github.com/heartsentwined/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

helper zf2 cli

07/09 2012

1.0.0

1.0.0.0 https://github.com/heartsentwined/zf2-cli

helper functions for building a zf2 CLI app

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

helper zf2 cli