PHPackages                             windwalker/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. [Framework](/categories/framework)
4. /
5. windwalker/console

ActiveWindwalker-package[Framework](/categories/framework)

windwalker/console
==================

Windwalker Controller package

3.5.23(5y ago)214.2k3LGPL-2.0-or-laterPHPPHP &gt;=7.1.3

Since Oct 5Pushed 2y ago3 watchersCompare

[ Source](https://github.com/windwalker-io/console)[ Packagist](https://packagist.org/packages/windwalker/console)[ Docs](https://github.com/ventoviro/windwalker-console)[ RSS](/packages/windwalker-console/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (83)Used By (3)

Windwalker Console
==================

[](#windwalker-console)

The Windwalker Console package provides an elegant and nested command structure for your cli application.

Installation via Composer
-------------------------

[](#installation-via-composer)

Add this to the require block in your `composer.json`.

```
{
    "require": {
        "windwalker/console": "~3.0"
    }
}
```

The Nested Command Structure
----------------------------

[](#the-nested-command-structure)

```
          Console Application (RootCommand)
                         |
              ----------------------
              |                    |
          CommandA              CommandB
              |                    |
        ------------          ------------
        |          |          |          |
    CommandC   CommandD    CommandE   CommandF

```

If we type:

```
$ php cli/console.php commandA commandC foo bar -a -bc -d=e --flower=sakura
```

Then we will been direct to `CommandC` class, and the following `foo bar` will be arguments.

```
class CommandC extend AbstractCommand
{
    public function execute()
    {
        $arg1 = $this->getArgument(0); // foo
        $arg2 = $this->getArgument(0); // bar

        $opt = $this->io->get('d') // e
        $opt = $this->io->get('flower') // sakura
    }
}
```

Initialising Console
--------------------

[](#initialising-console)

Console is the main application help us create a command line program.

An example console application skeleton in `cli/console.php` file:

```
