PHPackages                             polonaiz/cli-options-parser - 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. polonaiz/cli-options-parser

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

polonaiz/cli-options-parser
===========================

Command line arguments/options parser.

v1.2.2(5y ago)0347BSD-3-ClausePHPPHP &gt;=7.0

Since Mar 29Pushed 5y agoCompare

[ Source](https://github.com/polonaiz/cli-options-parser)[ Packagist](https://packagist.org/packages/polonaiz/cli-options-parser)[ Docs](https://phalconphp.com)[ RSS](/packages/polonaiz-cli-options-parser/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

Cop
===

[](#cop)

[![Software License](https://camo.githubusercontent.com/6d26d332b8585ddfa7cad3eb06faf3775675c7f259aaa38d80832af69a08c0b6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d627269676874677265656e2e737667)](https://github.com/phalcon/cli-options-parser/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/ff809e1c95f7cbe92769b08063a82d473957dc0d118a7182d1d37b7bc90d7bed/68747470733a2f2f7472617669732d63692e6f72672f7068616c636f6e2f636c692d6f7074696f6e732d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phalcon/cli-options-parser)[![Code Coverage](https://camo.githubusercontent.com/f36c066f4a7a0913bdf75762da03b8a431117473e540a2cd739b715342fda7ff/68747470733a2f2f636f6465636f762e696f2f67682f7068616c636f6e2f636c692d6f7074696f6e732d7061727365722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/phalcon/cli-options-parser)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f35c70c21a91ea81c337467eb74152e22bb98fa17e57996ec1e353340f19c603/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068616c636f6e2f636c692d6f7074696f6e732d7061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phalcon/cli-options-parser/?branch=master)[![Scrutinizer Build Status](https://camo.githubusercontent.com/dfc68a1d2ba9c23e7391b790b68ca926facc1ae145e62e50cc5c2783e2b880c8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068616c636f6e2f636c692d6f7074696f6e732d7061727365722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phalcon/cli-options-parser/build-status/master)

Command line arguments/options parser.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.0

Installing via [Composer](https://getcomposer.org)
--------------------------------------------------

[](#installing-via-composer)

Install composer in a common location or in your project:

```
composer require phalcon/cli-options-parser
```

Usage
-----

[](#usage)

```
use Phalcon\Cop\Parser;

$parser = new Parser();

// Parse params from the $argv
$params = $parser->parse($argv);

// Parse params from the $_SERVER['argv']
$params = $parser->parse();

// After parsing input, Parser provides a way to gets booleans:
$parser->getBoolean('foo');

// Get param `foo` or return TRUE as a default value
$parser->getBoolean('foo', true);
```

### Examples

[](#examples)

```
php test.php -az value1 -abc value2
[
    'a' => 'value2',
    'z' => 'value1',
    'b' => 'value2',
    'c' => 'value2',
]

php test.php -a value1 -abc value2
[
    'a'  => 'value2',
    'b'  => 'value2',
    'c'  => 'value2',
]

php test.php --az value1 --abc value2
[
    'az'  => 'value1',
    'abc' => 'value2',
]

php test.php --foo --bar=baz --spam eggs
[
    'foo'  => true,
    'bar'  => 'baz',
    'spam' => 'eggs',
]

php test.php -abc foo
[
    'a' => 'foo',
    'b' => 'foo',
    'c' => 'foo',
]

php test.php arg1 arg2 arg3
[
    0 => 'arg1',
    1 => 'arg2',
    2 => 'arg3',
]

php test.php \
    plain-arg \
    --foo \
    --bar=baz \
    --funny="spam=eggs" \
    --also-funny=spam=eggs \
    'plain arg 2'
    -abc \
    -k=value \
    "plain arg 3" \
    --s="original" \
    --s='overwrite' \
    --s
[
    0            => 'plain-arg',
    'foo'        => true,
    'bar'        => 'baz',
    'funny'      => 'spam=eggs',
    'also-funny' => 'spam=eggs',
    1            => 'plain arg 2',
    'a'          => true,
    'b'          => true,
    'c'          => true,
    'k'          => 'value',
    2            => 'plain arg 3',
    's'          => 'overwrite',
]

```

License
-------

[](#license)

The Cop is open source software licensed under the [New BSD License](https://github.com/phalcon/cli-options-parser/blob/master/LICENSE.txt).
© Phalcon Team

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 50.7% 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 ~254 days

Total

5

Last Release

1952d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.0

v1.2.0PHP &gt;=7.0 &lt;8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b438ce417cd4cf902e2d1410a87fda07d67413688504b1cbd6ee306ab4e7a59e?d=identicon)[polonaiz](/maintainers/polonaiz)

---

Top Contributors

[![sergeyklay](https://avatars.githubusercontent.com/u/1256298?v=4)](https://github.com/sergeyklay "sergeyklay (35 commits)")[![niden](https://avatars.githubusercontent.com/u/1073784?v=4)](https://github.com/niden "niden (19 commits)")[![sergeysviridenko](https://avatars.githubusercontent.com/u/26042973?v=4)](https://github.com/sergeysviridenko "sergeysviridenko (4 commits)")[![CameronHall](https://avatars.githubusercontent.com/u/7316093?v=4)](https://github.com/CameronHall "CameronHall (3 commits)")[![Jeckerson](https://avatars.githubusercontent.com/u/3289702?v=4)](https://github.com/Jeckerson "Jeckerson (3 commits)")[![adam-rocska](https://avatars.githubusercontent.com/u/1914616?v=4)](https://github.com/adam-rocska "adam-rocska (2 commits)")[![urlund](https://avatars.githubusercontent.com/u/376721?v=4)](https://github.com/urlund "urlund (2 commits)")[![polonaiz](https://avatars.githubusercontent.com/u/6059038?v=4)](https://github.com/polonaiz "polonaiz (1 commits)")

---

Tags

clicommand-lineterminalparseroptioncommandgetoptlineoptparseargparse

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/polonaiz-cli-options-parser/health.svg)

```
[![Health](https://phpackages.com/badges/polonaiz-cli-options-parser/health.svg)](https://phpackages.com/packages/polonaiz-cli-options-parser)
```

###  Alternatives

[phalcon/cli-options-parser

Command line arguments/options parser.

181.0M7](/packages/phalcon-cli-options-parser)[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[splitbrain/php-cli

Easy command line scripts for PHP with opt parsing and color output. No dependencies

177817.2k28](/packages/splitbrain-php-cli)[league/climate

PHP's best friend for the terminal. CLImate allows you to easily output colored text, special formats, and more.

1.9k14.0M273](/packages/league-climate)[nategood/commando

PHP CLI Commando Style

8123.3M38](/packages/nategood-commando)[aura/cli

Provides the equivalent of request (Context) and response (Stdio) classes for a command line environment, including Getopt support.

1051.6M29](/packages/aura-cli)

PHPackages © 2026

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