PHPackages                             pwfisher/command-line-php - 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. pwfisher/command-line-php

ActiveLibrary

pwfisher/command-line-php
=========================

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

64328.8k—0%13[5 issues](https://github.com/pwfisher/CommandLine.php/issues)[1 PRs](https://github.com/pwfisher/CommandLine.php/pulls)PHP

Since Sep 23Pushed 10y ago3 watchersCompare

[ Source](https://github.com/pwfisher/CommandLine.php)[ Packagist](https://packagist.org/packages/pwfisher/command-line-php)[ RSS](/packages/pwfisher-command-line-php/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

CommandLine.php
===============

[](#commandlinephp)

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

### Usage

[](#usage)

```
$args = CommandLine::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

32

—

LowBetter than 74% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/pwfisher-command-line-php/health.svg)

```
[![Health](https://phpackages.com/badges/pwfisher-command-line-php/health.svg)](https://phpackages.com/packages/pwfisher-command-line-php)
```

PHPackages © 2026

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