PHPackages                             barbowza/parse-args - 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. barbowza/parse-args

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

barbowza/parse-args
===================

PHP Command Line Arguments parsing utility class. Provides friendly and flexible CLI argument parsing.

v1.0.1(3y ago)013CC-BY-3.0PHPPHP &gt;=8.1

Since Aug 25Pushed 3y agoCompare

[ Source](https://github.com/barbowza/ParseArgs)[ Packagist](https://packagist.org/packages/barbowza/parse-args)[ RSS](/packages/barbowza-parse-args/feed)WikiDiscussions master Synced 1mo ago

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

ParseArgs.php
=============

[](#parseargsphp)

PHP Command Line Arguments parsing utility class. Provides friendly and flexible CLI argument parsing.

### Usage

[](#usage)

```
$args = ParseArgs::parseArgs($_SERVER['argv']);

```

This command line option parser supports any combination of three types of options \[single character options (`-a -b` or `-ab` or `-c -d=dog` or `-cd dog`), long options (`--foo` or `--bar=baz` or `--bar baz`) and arguments (`arg1 arg2`)\] and returns a simple array.

```
[pfisher ~]$ php test.php --foo --bar=baz --spam eggs
  ["foo"]   => true
  ["bar"]   => "baz"
  ["spam"]  => "eggs"

[pfisher ~]$ php test.php -abc foo
  ["a"]     => true
  ["b"]     => true
  ["c"]     => "foo"

[pfisher ~]$ php test.php arg1 arg2 arg3
  [0]       => "arg1"
  [1]       => "arg2"
  [2]       => "arg3"

[pfisher ~]$ 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"

```

Not supported: `-cd=dog`.

@author Patrick Fisher

@since August 21, 2009

@see

-
- comment #81042 function arguments($argv) by technorati at gmail dot com, 12-Feb-2008
- comment #78651 function getArgs($args) by B Crawford, 22-Oct-2007

Note: parseArgs.php contains a "minified" version of the same code, for your copypasta pleasure. For little scripts for which you want to have a nice interface.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~0 days

Total

2

Last Release

1362d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38b2488de44c0d5d056fdc814b5538de8f56856f19d539605c33114e42c42f6e?d=identicon)[Barbowza](/maintainers/Barbowza)

---

Top Contributors

[![pwfisher](https://avatars.githubusercontent.com/u/126581?v=4)](https://github.com/pwfisher "pwfisher (20 commits)")[![barbowza](https://avatars.githubusercontent.com/u/8808502?v=4)](https://github.com/barbowza "barbowza (6 commits)")[![honzabrecka](https://avatars.githubusercontent.com/u/1021827?v=4)](https://github.com/honzabrecka "honzabrecka (2 commits)")

---

Tags

cliparserparsing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/barbowza-parse-args/health.svg)

```
[![Health](https://phpackages.com/badges/barbowza-parse-args/health.svg)](https://phpackages.com/packages/barbowza-parse-args)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)[kzykhys/ciconia

The Markdown parser for PHP5.4

35366.7k13](/packages/kzykhys-ciconia)

PHPackages © 2026

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