PHPackages                             danack/console - 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. danack/console

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

danack/console
==============

Refactored Symfony Console Component

v2.6.3(5mo ago)812.0k↓100%1[3 issues](https://github.com/Danack/Console/issues)MITPHPPHP &gt;=5.3.3

Since Sep 22Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/Danack/Console)[ Packagist](https://packagist.org/packages/danack/console)[ Docs](http://console.basereality.com/)[ RSS](/packages/danack-console/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

Console Router
==============

[](#console-router)

[![Build Status](https://camo.githubusercontent.com/cb4da9dc79f7049bb36d35aa6b596afdad8dba7459a1c57696f15041709e80fb/68747470733a2f2f7472617669732d63692e6f72672f44616e61636b2f436f6e736f6c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Danack/Console)

This is not the Symfony console - it is a forking refactor to:

- To split the 'routing' and dispatching of commands.
- Remove the events, because they don't belong in what should be a reasonable, simple piece of code.
- Stop the console application catching and dumping exceptions when it has no idea how to handle them.

Basically although most of the Symfony/console library does a great job, the fact that you have to let it run the application is stupid. The console library should stick to console stuff, you should then be able to run the application yourself.

The example below shows how to create commands with a callable, have the console application 'route' the input, and then run the callable with [Auryn](https://github.com/rdlowrey/Auryn).

```
$console = new Application();
$console->add(new AboutCommand());

// Create a command that will call the function 'uploadFile'
$uploadCommand = new Command('uploadFile', 'upload');
$uploadCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the thing to foo');
$console->add($uploadCommand);

$helloWorldCallable = function ($name) {
    echo "Hello world, and particularly $name".PHP_EOL;
};

// Create a command that will call the closure
$callableCommand = new Command($helloWorldCallable, 'greet');
$callableCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the person to say hello to.');
$console->add($callableCommand);

try {
    $parsedCommand = $console->parseCommandLine();
}
catch (\Exception $e) {
    $output = new BufferedOutput();
    $console->renderException($e, $output);
    echo $output->fetch();
    exit(-1);
}

$provider = new Auryn\Provider();
$provider->execute(
    $parsedCommand->getCallable(),
    lowrey($parsedCommand->getParams())
);

function uploadFile($filename) {
    echo "Need to upload the file $filename".PHP_EOL;
}

// Auryn needs scalars prefixed with a colon
function lowrey($params) {
    $newParams = [];
    foreach ($params as $key => $value) {
        $newParams[':'.$key] = $value;
    }
    return $newParams;
}
```

If the example above was in the file example.php running the command `php example.php greet Danack` would output:

> Hello world, and particularly Danack

\\o/

If you want to see an example running please run the file Tests/example.php with some appropriate arguments e.g.:

- php Tests/example.php upload backup.zip --dir=/var/log
- php Tests/example.php greet Danack
- php Tests/example.php greet

Will show the 'upload' and 'greet' commands being routed correctly

Migrating from Symfony/console
------------------------------

[](#migrating-from-symfonyconsole)

The only major work needed to migrate from Symfony/console to Danack/console is to change any command objects to return a callable instead of having an execute method.

This includes commands that just display information rather than having a 'proper' executable e.g. the [ListCommand](https://github.com/Danack/Console/blob/master/lib/Danack/Console/Command/ListCommand.php).

Then just change from:

- Application::run which runs the command and returns a status code

to

- Application::parseCommandLine which just parsed the command line args and returns a ParsedCommand object.

Previous readme
---------------

[](#previous-readme)

Console eases the creation of beautiful and testable command line interfaces.

Tests
-----

[](#tests)

You can run the unit tests with the following command:

```
$ cd path/to/Symfony/Component/Console/
$ composer.phar install
$ phpunit
```

Third Party
-----------

[](#third-party)

`Resources/bin/hiddeninput.exe` is a third party binary provided within this component. Find sources and license at .

Resources
---------

[](#resources)

[The Console Component](http://symfony.com/doc/current/components/console.html)

[How to create a Console Command](http://symfony.com/doc/current/cookbook/console/console_command.html)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance64

Regular maintenance activity

Popularity29

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 59.3% 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 ~1345 days

Total

4

Last Release

163d ago

### Community

Maintainers

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

---

Top Contributors

[![fabpot](https://avatars.githubusercontent.com/u/47313?v=4)](https://github.com/fabpot "fabpot (396 commits)")[![Danack](https://avatars.githubusercontent.com/u/1505719?v=4)](https://github.com/Danack "Danack (34 commits)")[![jfsimon](https://avatars.githubusercontent.com/u/119407?v=4)](https://github.com/jfsimon "jfsimon (34 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (33 commits)")[![Tobion](https://avatars.githubusercontent.com/u/610090?v=4)](https://github.com/Tobion "Tobion (21 commits)")[![lyrixx](https://avatars.githubusercontent.com/u/408368?v=4)](https://github.com/lyrixx "lyrixx (14 commits)")[![everzet](https://avatars.githubusercontent.com/u/30813?v=4)](https://github.com/everzet "everzet (13 commits)")[![romainneutron](https://avatars.githubusercontent.com/u/137574?v=4)](https://github.com/romainneutron "romainneutron (13 commits)")[![jakzal](https://avatars.githubusercontent.com/u/190447?v=4)](https://github.com/jakzal "jakzal (11 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (11 commits)")[![hason](https://avatars.githubusercontent.com/u/288535?v=4)](https://github.com/hason "hason (8 commits)")[![lmcd](https://avatars.githubusercontent.com/u/363540?v=4)](https://github.com/lmcd "lmcd (8 commits)")[![nanocom](https://avatars.githubusercontent.com/u/667482?v=4)](https://github.com/nanocom "nanocom (7 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (6 commits)")[![webmozart](https://avatars.githubusercontent.com/u/176399?v=4)](https://github.com/webmozart "webmozart (6 commits)")[![kriswallsmith](https://avatars.githubusercontent.com/u/33886?v=4)](https://github.com/kriswallsmith "kriswallsmith (5 commits)")[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (5 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (5 commits)")[![canni](https://avatars.githubusercontent.com/u/385754?v=4)](https://github.com/canni "canni (4 commits)")[![dlsniper](https://avatars.githubusercontent.com/u/607868?v=4)](https://github.com/dlsniper "dlsniper (4 commits)")

---

Tags

cliconsole

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danack-console/health.svg)

```
[![Health](https://phpackages.com/badges/danack-console/health.svg)](https://phpackages.com/packages/danack-console)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

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

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

4.6k324.1M7.0k](/packages/nunomaduro-collision)[nunomaduro/termwind

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

2.5k230.3M225](/packages/nunomaduro-termwind)[wp-cli/php-cli-tools

Console utilities for PHP

68324.1M327](/packages/wp-cli-php-cli-tools)[php-school/cli-menu

A command line menu helper in PHP

2.0k1.1M21](/packages/php-school-cli-menu)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.5M14](/packages/seld-cli-prompt)

PHPackages © 2026

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