Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A collection of tools to help with command line development in PHP 5.3

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 composer.json
Octocat-spinner-32 http-console.php
Octocat-spinner-32 test.php

PHP Command Line Tools

A collection of functions and classes to assist with command line development.


  • PHP >= 5.3

Function List

  • \cli\out($msg, ...)
  • \cli\out_padded($msg, ...)
  • \cli\err($msg, ...)
  • \cli\line($msg = '', ...)
  • \cli\input()
  • \cli\prompt($question, $default = false, $marker = ':')
  • \cli\choose($question, $choices = 'yn', $default = 'n')
  • \cli\menu($items, $default = false, $title = 'Choose an Item')

Progress Indicators

  • \cli\notifier\Dots($msg, $dots = 3, $interval = 100)
  • \cli\notifier\Spinner($msg, $interval = 100)
  • \cli\progress\Bar($msg, $total, $interval = 100)

Tabular Display

  • \cli\Table::__construct(array $headers = null, array $rows = null)
  • \cli\Table::setHeaders(array $headers)
  • \cli\Table::setRows(array $rows)
  • \cli\Table::setRenderer(\cli\table\Renderer $renderer)
  • \cli\Table::addRow(array $row)
  • \cli\Table::sort($column)
  • \cli\Table::display()

The display function will detect if output is piped and, if it is, render a tab delimited table instead of the ASCII table rendered for visual display.

You can also explicitly set the renderer used by calling \cli\Table::setRenderer() and giving it an instance of one of the concrete \cli\table\Renderer classes.

Argument Parser

Argument parsing uses a simple framework for taking a list of command line arguments, usually straight from $_SERVER['argv'], and parses the input against a set of defined rules.

Check example_args.php for an example.


See example.php for examples.


  • Expand this README
  • Add doc blocks to rest of code
Something went wrong with that request. Please try again.