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.1M↑22%88BSD-3-ClausePHPPHP &gt;=8.0CI passing

Since Mar 29Pushed 4w 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 2w ago

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

Phalcon - CLI Options Parser
============================

[](#phalcon---cli-options-parser)

[![CLI Options Parser CI](https://github.com/phalcon/cli-options-parser/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/phalcon/cli-options-parser/actions/workflows/main.yml)[![Quality Gate Status](https://camo.githubusercontent.com/4c011824ec694c570fb57a688e491949293cb28e5fbaac58ffa135a88a7d602c/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7068616c636f6e5f636c692d6f7074696f6e732d706172736572266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=phalcon_cli-options-parser)[![Coverage](https://camo.githubusercontent.com/d9480ad8917ae5482cc0d4665d7636cffe3c725f952a6dd52563cf5a886612d0/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7068616c636f6e5f636c692d6f7074696f6e732d706172736572266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=phalcon_cli-options-parser)[![PDS Skeleton](https://camo.githubusercontent.com/50d01a5094afcc3a827c3cadaec43d23b2a256cb249f5fdd6e5ffdb53ea7971c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7064732d736b656c65746f6e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/php-pds/skeleton)[![Downloads](https://camo.githubusercontent.com/8810b4680a7a77c79ee69216699d42a0804350e2abb48b3962f0208aca8b07d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7068616c636f6e2f636c692d6f7074696f6e732d706172736572)](https://packagist.org/packages/phalcon/cli-options-parser)

Command line arguments/options parser.

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

[](#requirements)

- PHP &gt;= 8.0

Installation
------------

[](#installation)

You can install the package using composer

```
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 get 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',
]

```

Development
-----------

[](#development)

The repository ships a Docker setup for local development and testing. You only need Docker + Docker Compose; the PHP runtime is provided inside the container.

### Quick start

[](#quick-start)

```
docker compose up -d --build
docker compose exec app composer install
docker compose exec app composer test
```

> `app` is the Compose *service* name; the running container is `cli-options-parser-app`. It stays up via a `sleep infinity` keepalive, so you can `docker compose exec app ` freely.

### Choosing the PHP version

[](#choosing-the-php-version)

The image is built for one PHP version at a time via the `PHP_VERSION` build arg (default `8.4`; supported `8.0`–`8.4`). Because it is a **build** arg, changing it requires a rebuild:

```
docker compose up -d --build                  # PHP 8.4 (default)
PHP_VERSION=8.0 docker compose up -d --build  # PHP 8.0
```

### Composer scripts

[](#composer-scripts)

ScriptDescription`composer cs`PHP\_CodeSniffer (PSR-12)`composer cs-fix`Auto-fix coding-standard issues (phpcbf)`composer cs-fixer`PHP CS Fixer (dry-run)`composer cs-fixer-fix`Apply PHP CS Fixer`composer analyze`PHPStan static analysis (level max)`composer test`Unit tests (PHPUnit)`composer test-coverage`Tests + Clover coverage (`tests/_output/coverage.xml`)License
-------

[](#license)

CLI Options Parser is open source software licensed under the [BSD-3-Clause License](LICENSE).

© Phalcon Team

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance62

Regular maintenance activity

Popularity49

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

997d 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://avatars.githubusercontent.com/u/1221505?v=4)[The Phalcon PHP Framework](/maintainers/phalcon)[@phalcon](https://github.com/phalcon)

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

---

Top Contributors

[![niden](https://avatars.githubusercontent.com/u/1073784?v=4)](https://github.com/niden "niden (53 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 (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![Ultimater](https://avatars.githubusercontent.com/u/1922199?v=4)](https://github.com/Ultimater "Ultimater (4 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)")[![urlund](https://avatars.githubusercontent.com/u/376721?v=4)](https://github.com/urlund "urlund (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.2B15.1k](/packages/symfony-console)[splitbrain/php-cli

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

178884.6k37](/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.9k15.0M314](/packages/league-climate)[nategood/commando

PHP CLI Commando Style

8013.4M40](/packages/nategood-commando)[aura/cli

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

1021.6M34](/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)
