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

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

fidry/console
=============

Library to create CLI applications

0.6.11(1y ago)192.0M↓12.6%3[6 issues](https://github.com/theofidry/console/issues)[4 PRs](https://github.com/theofidry/console/pulls)2MITPHPPHP ^8.2CI failing

Since May 14Pushed 1y ago3 watchersCompare

[ Source](https://github.com/theofidry/console)[ Packagist](https://packagist.org/packages/fidry/console)[ GitHub Sponsors](https://github.com/theofidry)[ RSS](/packages/fidry-console/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (19)Versions (29)Used By (2)

Console
-------

[](#console)

Motivation: this library purpose is to provide a lighter and more robust API for console commands and/or applications to [symfony/console](https://github.com/symfony/console).

It can be used either in combination with [`FrameworkBundle`](https://github.com/symfony/framework-bundle) to facilitate the creation of commands or as a stand-alone package to create a CLI application app.

Key differences:

- Leverages an `IO` object instead of Input + Output + SymfonyStyle which offers:
    - The API of SymfonyStyle but still access to the Input and Output objects
    - A typed API for arguments and options (the input is validated when coercing it to a stricter type)
- Implement explicit interfaces instead of extending god classes

Table of Contents
-----------------

[](#table-of-contents)

- [Installation with Symfony](#installation-with-symfony)
- [Usage preview](#usage-preview)
- [Complete documentation](#complete-documentation)
    - [Command](./doc/command.md)
        - [Creating a command](./doc/command.md#creating-a-command)
        - [Configuring the Command](./doc/command.md#configuring-the-command)
        - [Registering the Command](./doc/command.md#registering-the-command)
        - [Executing the Command](./doc/command.md#executing-the-command)
        - [Console Output](./doc/command.md#console-output)
        - [Output Sections](./doc/command.md#output-sections)
        - [Console Input](./doc/command.md#console-input)
        - [Getting Services from the Service Container](./doc/command.md#getting-services-from-the-service-container)
        - [Command Lifecycle](./doc/command.md#command-lifecycle)
        - [Testing Commands](./doc/command.md#testing-commands)
        - [Logging Command Errors](./doc/command.md#logging-command-errors)
        - [Learn More](./doc/command.md#learn-more)
    - [How to Call Other Commands](./doc/call-other-commands.md)
    - [How to Make Commands Lazily Loaded](./doc/lazy-command.md)
    - [Application](./doc/application.md)
        - [Creating an application](./doc/application.md#creating-an-application)
        - [Executing an Application](./doc/application.md#executing-an-application)
    - [Testing](./doc/testing.md)
        - [Testing an Application](./doc/testing.md#testing-an-application)
        - [Testing a Command](./doc/testing.md#testing-a-command)
- [Known Limitations](#known-limitations)
- [Inspirations](#inspirations)
- [Contributing](#contributing)

### Installation with Symfony

[](#installation-with-symfony)

```
$ composer require theofidry/console

```

The Symfony Flex plugin should add the following:

```
