PHPackages                             ulrichsg/getopt-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. [CLI &amp; Console](/categories/cli)
4. /
5. ulrichsg/getopt-php

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

ulrichsg/getopt-php
===================

Command line arguments parser for PHP 7.1 and above

v4.0.4(1y ago)3424.8M—1.8%63[2 issues](https://github.com/getopt-php/getopt-php/issues)[2 PRs](https://github.com/getopt-php/getopt-php/pulls)20MITPHPPHP ^7.1 || ^8.0CI failing

Since Jan 4Pushed 1mo ago9 watchersCompare

[ Source](https://github.com/getopt-php/getopt-php)[ Packagist](https://packagist.org/packages/ulrichsg/getopt-php)[ Docs](http://getopt-php.github.io/getopt-php)[ RSS](/packages/ulrichsg-getopt-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (49)Used By (20)

GetOpt.PHP
==========

[](#getoptphp)

[![.github/workflows/push.yml](https://github.com/getopt-php/getopt-php/actions/workflows/push.yml/badge.svg)](https://github.com/getopt-php/getopt-php/actions/workflows/push.yml)[![Test Coverage](https://camo.githubusercontent.com/43711d1e17fb903081c7c5cc606ff2b374aa2e9e8fdff51f6d9f99a821188c2f/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32663062393538366633663639643639303634372f746573745f636f766572616765)](https://codeclimate.com/github/getopt-php/getopt-php/test_coverage)[![Maintainability](https://camo.githubusercontent.com/07ab382272268f0bbd0e792a9073c1fb572047085e35485c6e5ee8c847a79b43/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32663062393538366633663639643639303634372f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/getopt-php/getopt-php/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/598396efc6a77441bd20f0506a23ee6a9927de9ac0561b0300584817d256cbfb/68747470733a2f2f706f7365722e707567782e6f72672f756c7269636873672f6765746f70742d7068702f762f737461626c652e737667)](https://packagist.org/packages/ulrichsg/getopt-php)[![Total Downloads](https://camo.githubusercontent.com/6e57b0b6205e1888e8f386522a4cc0241c4ca29030f0a8634d96a0d19891f92a/68747470733a2f2f706f7365722e707567782e6f72672f756c7269636873672f6765746f70742d7068702f646f776e6c6f6164732e737667)](https://packagist.org/packages/ulrichsg/getopt-php)[![License](https://camo.githubusercontent.com/cbf692457a7cbd9ba2059fab160b61b5b68893e300451c8e6a15a1458bf86c8e/68747470733a2f2f706f7365722e707567782e6f72672f756c7269636873672f6765746f70742d7068702f6c6963656e73652e737667)](https://packagist.org/packages/ulrichsg/getopt-php)

GetOpt.PHP is a library for command-line argument processing. It supports PHP version 7.1 and above.

Releases
--------

[](#releases)

For an overview of the releases with a changelog please have look here:

Features
--------

[](#features)

- Supports both short (e.g. `-v`) and long (e.g. `--version`) options
- Option aliasing, ie. an option can have both a long and a short version
- Cumulative short options (e.g. `-vvv`)
- Two alternative notations for long options with arguments: `--option value` and `--option=value`
- Collapsed short options (e.g. `-abc` instead of `-a -b -c`), also with an argument for the last option (e.g. `-ab 1` instead of `-a -b 1`)
- Two alternative notations for short options with arguments: `-o value` and `-ovalue`
- Quoted arguments (e.g. `--path "/some path/with spaces"`) for string processing
- Options with multiple arguments (e.g. `--domain example.org --domain example.com`)
- Operand (positional arguments) specification, validation and limitation
- Command routing with specified options and operands
- Help text generation
- Default argument values
- Argument validation

Upgrading
---------

[](#upgrading)

If you are still using a legacy version of GetOpt.PHP, please consider upgrading to version 3.

Only a few adjustments to your code are required to benefit from a lot of improvements. Refer to the [upgrade guide](https://getopt-php.github.io/getopt-php/upgrade.html) for details.

Documentation
-------------

[](#documentation)

- [Documentation for the current version (3.0+)](http://getopt-php.github.io/getopt-php/)
- [Legacy documentation (1.4)](https://github.com/getopt-php/getopt-php/blob/1.4.1/README.markdown)

License
-------

[](#license)

GetOpt.PHP is published under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance69

Regular maintenance activity

Popularity64

Solid adoption and visibility

Community47

Growing community involvement

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 65.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 ~111 days

Recently: every ~345 days

Total

44

Last Release

461d ago

Major Versions

1.4.1 → 2.0.02014-01-30

2.3.0 → v3.x-dev2015-04-07

2.4.3 → 3.0.0-alpha.32017-07-26

v3.4.0 → v4.0.0-alpha.12021-02-18

PHP version history (5 changes)1.0.0PHP &gt;=5.3.0

3.0.0-alpha.3PHP &gt;=5.4.0

v4.0.0-alpha.1PHP &gt;=7.1.0

v4.0.2PHP &gt;=7.1 || ^8.0

v4.0.3PHP ^7.1 || ^8.0

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/4855611?v=4)[Thomas Flori](/maintainers/tflori)[@tflori](https://github.com/tflori)

---

Top Contributors

[![tflori](https://avatars.githubusercontent.com/u/4855611?v=4)](https://github.com/tflori "tflori (203 commits)")[![ulrichsg](https://avatars.githubusercontent.com/u/197901?v=4)](https://github.com/ulrichsg "ulrichsg (45 commits)")[![dregad](https://avatars.githubusercontent.com/u/449891?v=4)](https://github.com/dregad "dregad (10 commits)")[![jochenvdv](https://avatars.githubusercontent.com/u/6173051?v=4)](https://github.com/jochenvdv "jochenvdv (6 commits)")[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (5 commits)")[![graste](https://avatars.githubusercontent.com/u/203540?v=4)](https://github.com/graste "graste (5 commits)")[![JanMikes](https://avatars.githubusercontent.com/u/3995003?v=4)](https://github.com/JanMikes "JanMikes (5 commits)")[![avargas](https://avatars.githubusercontent.com/u/169653?v=4)](https://github.com/avargas "avargas (3 commits)")[![AdamSGit](https://avatars.githubusercontent.com/u/6126439?v=4)](https://github.com/AdamSGit "AdamSGit (2 commits)")[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (2 commits)")[![geoffroy-aubry](https://avatars.githubusercontent.com/u/1247448?v=4)](https://github.com/geoffroy-aubry "geoffroy-aubry (2 commits)")[![kamermans](https://avatars.githubusercontent.com/u/266265?v=4)](https://github.com/kamermans "kamermans (2 commits)")[![PierrickVoulet](https://avatars.githubusercontent.com/u/6769971?v=4)](https://github.com/PierrickVoulet "PierrickVoulet (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![jonasraoni](https://avatars.githubusercontent.com/u/361921?v=4)](https://github.com/jonasraoni "jonasraoni (1 commits)")[![jwieder](https://avatars.githubusercontent.com/u/5055990?v=4)](https://github.com/jwieder "jwieder (1 commits)")[![christiaan](https://avatars.githubusercontent.com/u/118490?v=4)](https://github.com/christiaan "christiaan (1 commits)")[![kler](https://avatars.githubusercontent.com/u/966132?v=4)](https://github.com/kler "kler (1 commits)")[![kwhat](https://avatars.githubusercontent.com/u/676164?v=4)](https://github.com/kwhat "kwhat (1 commits)")[![malaire](https://avatars.githubusercontent.com/u/6322120?v=4)](https://github.com/malaire "malaire (1 commits)")

---

Tags

argument-parserargumentsclicommand-linephp

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ulrichsg-getopt-php/health.svg)

```
[![Health](https://phpackages.com/badges/ulrichsg-getopt-php/health.svg)](https://phpackages.com/packages/ulrichsg-getopt-php)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

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