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

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

phalcon/cli-options-parser
==========================

Command line arguments/options parser.

v2.0.0(2y ago)181.0M—7.2%87BSD-3-ClausePHPPHP &gt;=8.0CI passing

Since Mar 29Pushed 8mo ago9 watchersCompare

[ Source](https://github.com/phalcon/cli-options-parser)[ Packagist](https://packagist.org/packages/phalcon/cli-options-parser)[ Docs](https://phalconphp.com)[ GitHub Sponsors](https://github.com/phalcon)[ Fund](https://opencollective.com/phalcon)[ RSS](/packages/phalcon-cli-options-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (7)

Cop
===

[](#cop)

[![PDS Skeleton](https://camo.githubusercontent.com/50d01a5094afcc3a827c3cadaec43d23b2a256cb249f5fdd6e5ffdb53ea7971c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7064732d736b656c65746f6e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/php-pds/skeleton)[![GitHub License](https://camo.githubusercontent.com/10a5869fa65e3f4725a07addeef074c652b8e61470d23a7f21fb349abb5d95e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068616c636f6e2f636c692d6f7074696f6e732d706172736572)](https://camo.githubusercontent.com/10a5869fa65e3f4725a07addeef074c652b8e61470d23a7f21fb349abb5d95e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068616c636f6e2f636c692d6f7074696f6e732d706172736572)[![Codacy Grade](https://camo.githubusercontent.com/c5df1a3f42802cd71448ffe612f1e58d8872588f806653e914c5cf1ceda4fa41/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f3430363463396263333536333435303538353265343161656461613933383663)](https://camo.githubusercontent.com/c5df1a3f42802cd71448ffe612f1e58d8872588f806653e914c5cf1ceda4fa41/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f3430363463396263333536333435303538353265343161656461613933383663)[![Codacy Code Coverage](https://camo.githubusercontent.com/2f5ff627d25de0268671a2bb0e72b37e698dc4f390de8f96505aeaf66fd288e2/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f636f7665726167652f3430363463396263333536333435303538353265343161656461613933383663)](https://camo.githubusercontent.com/2f5ff627d25de0268671a2bb0e72b37e698dc4f390de8f96505aeaf66fd288e2/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f636f7665726167652f3430363463396263333536333435303538353265343161656461613933383663)[![Downloads](https://camo.githubusercontent.com/8810b4680a7a77c79ee69216699d42a0804350e2abb48b3962f0208aca8b07d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7068616c636f6e2f636c692d6f7074696f6e732d706172736572)](https://camo.githubusercontent.com/8810b4680a7a77c79ee69216699d42a0804350e2abb48b3962f0208aca8b07d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7068616c636f6e2f636c692d6f7074696f6e732d706172736572)

Command line arguments/options parser.

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

[](#requirements)

- PHP &gt;= 8.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 [MIT License](https://github.com/phalcon/cli-options-parser/blob/master/LICENSE).

© Phalcon Team

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance43

Moderate activity, may be stable

Popularity48

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~344 days

Recently: every ~372 days

Total

7

Last Release

906d ago

Major Versions

v1.3.0 → v2.0.02023-11-24

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

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

1.3.x-devPHP &gt;=7.3

v2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/97049a4bd2f9716e97749f93fe32f8da0a3eeda4192772dec73a6a2531294cea?d=identicon)[klay](/maintainers/klay)

![](https://www.gravatar.com/avatar/826683026897842e5e89553da75daf5f8b4d0fe030761c876e2c8e2029942f8e?d=identicon)[phalcon](/maintainers/phalcon)

![](https://www.gravatar.com/avatar/9572c74793c58fd679e1cf2f769a5d5bcc6e0e14c3e73f0d41c5b26351eaa132?d=identicon)[ruudboon](/maintainers/ruudboon)

---

Top Contributors

[![niden](https://avatars.githubusercontent.com/u/1073784?v=4)](https://github.com/niden "niden (44 commits)")[![sergeyklay](https://avatars.githubusercontent.com/u/1256298?v=4)](https://github.com/sergeyklay "sergeyklay (35 commits)")[![Jeckerson](https://avatars.githubusercontent.com/u/3289702?v=4)](https://github.com/Jeckerson "Jeckerson (7 commits)")[![sergeysviridenko](https://avatars.githubusercontent.com/u/26042973?v=4)](https://github.com/sergeysviridenko "sergeysviridenko (4 commits)")[![Ultimater](https://avatars.githubusercontent.com/u/1922199?v=4)](https://github.com/Ultimater "Ultimater (4 commits)")[![CameronHall](https://avatars.githubusercontent.com/u/7316093?v=4)](https://github.com/CameronHall "CameronHall (3 commits)")[![urlund](https://avatars.githubusercontent.com/u/376721?v=4)](https://github.com/urlund "urlund (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![adam-rocska](https://avatars.githubusercontent.com/u/1914616?v=4)](https://github.com/adam-rocska "adam-rocska (2 commits)")

---

Tags

clicommandcommand-linegetoptlineoptionparserphalconclicommand-lineterminalparseroptioncommandgetoptlineoptparseargparse

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[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)[deweller/cliopts

A no-nonsense command-line options parser and help generator for PHP CLI apps.

1518.3k](/packages/deweller-cliopts)

PHPackages © 2026

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