PHPackages                             yalesov/zf2-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. yalesov/zf2-cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

yalesov/zf2-cli
===============

helper functions for building a zf2 CLI app

v2.1.3(9y ago)1942ISCPHPPHP &gt;=5.3.3

Since Sep 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/yalesov/zf2-cli)[ Packagist](https://packagist.org/packages/yalesov/zf2-cli)[ Docs](https://github.com/yalesov/zf2-cli)[ RSS](/packages/yalesov-zf2-cli/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (10)Used By (2)

zf2-cli
=======

[](#zf2-cli)

[![Build Status](https://camo.githubusercontent.com/4ba1e4d4d3c1284d8b38b1212d4cd95bc73cb1ce0c0bc8c53645e7109c93e3d8/68747470733a2f2f7472617669732d63692e6f72672f79616c65736f762f7a66322d636c692e737667)](https://travis-ci.org/yalesov/zf2-cli)

helper functions for building a zf2 CLI app

Installation
============

[](#installation)

[Composer](http://getcomposer.org/):

```
{
  "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**.

Usage
=====

[](#usage)

Get an instance of cli
----------------------

[](#get-an-instance-of-cli)

Use service locator.

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

Or just instantiate one manually.

```
$cli = new \Yalesov\Cli\Cli;
```

Templated-text
--------------

[](#templated-text)

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

### Setup templates

[](#setup-templates)

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

```
$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:

```
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`.

### Output text

[](#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.

You can also capture the output string instead of printing it directly:

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~174 days

Recently: every ~0 days

Total

9

Last Release

3595d ago

Major Versions

1.0.3 → v2.0.02016-07-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c284282a506ac3c908eda03eb11cc263a4457f2e3cc23cbe3e9b97830589e31?d=identicon)[yalesov](/maintainers/yalesov)

---

Top Contributors

[![yalesov](https://avatars.githubusercontent.com/u/20264293?v=4)](https://github.com/yalesov "yalesov (8 commits)")

---

Tags

clihelperzf2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yalesov-zf2-cli/health.svg)

```
[![Health](https://phpackages.com/badges/yalesov-zf2-cli/health.svg)](https://phpackages.com/packages/yalesov-zf2-cli)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M366](/packages/wp-cli-php-cli-tools)[buggregator/trap

A simple and powerful tool for debugging PHP applications.

2591.7M40](/packages/buggregator-trap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
