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

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

leaveyou/console
================

A set of console related components without the overhead of the illuminate framework

1.0.0(9y ago)1621MITPHPCI failing

Since Apr 1Pushed 4y ago3 watchersCompare

[ Source](https://github.com/Leaveyou/console)[ Packagist](https://packagist.org/packages/leaveyou/console)[ RSS](/packages/leaveyou-console/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)DependenciesVersions (5)Used By (0)

Console
=======

[](#console)

[![Travis](https://camo.githubusercontent.com/27ab07b6f5f987c737e0448f919a97c3d080c3bf22928c36cde83b8329d11f97/68747470733a2f2f6170702e7472617669732d63692e636f6d2f4c65617665796f752f636f6e736f6c652e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/github/Leaveyou/console)

A set of console components for parsing command line arguments

Features:
---------

[](#features)

- complex arguments recognition:

```
Parameters without value         --verbose -v -vv -vvv
Optional parameters with value   --optional=1970 -o=1970 -o1970 -o"1970"
Mandatory parameters with value  --required=1970 -r=1970 -r1970 -r"1970" --required 1970 -r 1970 -r "1970"

```

- Automatically generated help pages

```
$ php test.php --help
Asked for help page...
  -o,  --optional    Some example of an optional parameter
  -v,  --verbose     Whether verbose
       --account     This parameter doesn't have a description
       --mandatory   Mandatory parameter description. This should have one and only one value.
       --help        Shows this help message

```

- Dependency injection / container-ready
- Improves upon native php function `getopt()` shortcomings:
    - Treats `--version` and `-v` as the same parameter if defined as such.
    - Mandatory parameters are really MANDATORY
    - Optional parameters cannot have empty value
    - Allows to specify in advance if a parameter is a single string or a list of strings
    - Default values for optional parameters
    - @SOON: Support for trailing arbitrary data: `php x.php -abc [TRAILING] [DATA]` in PHP 5

Usage
-----

[](#usage)

```
