GetOpt.php is a command-line argument processor for PHP 5.4 and above. It started out as an object-oriented
replacement for PHP’s own
but has since evolved to become significantly more powerful.
- Supports both short (e.g.
-v) and long (e.g.
- Option aliasing, ie. an option can have both a long and a short version
- Cumulative short options (e.g.
- Two alternative notations for long options with arguments:
--option value and
- Collapsed short options (e.g.
-abc instead of
-a -b -c), also with an argument for the last option
-ab 1 instead of
-a -b 1)
- Two alternative notations for short options with arguments:
-o value and
- Quoted arguments (e.g.
--path "/some path/with spcaces") 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