An elegant PHP library for building command-line interfaces with clean syntax and automatic help generation.
Commando is a PHP library for building command-line interfaces (CLIs) that simplifies parsing command-line arguments and flags. It replaces PHP's native `$argv` and `getopt` with a more elegant, chainable API for defining options, validating input, and generating help documentation. It solves the problem of verbose and error-prone CLI script development by providing a clean, expressive syntax.
PHP developers who write command-line scripts, tools, or utilities and want a more maintainable and feature-rich alternative to manual argument parsing. It's ideal for those building internal tools, deployment scripts, or standalone CLI applications.
Developers choose Commando for its minimal boilerplate, fluent interface, and built-in features like automatic help generation and validation. It offers a more intuitive and readable way to handle CLI input compared to PHP's native options, without the bloat of larger CLI frameworks.
An Elegant CLI Library for PHP
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Chainable methods like `option()->require()->describedAs()` provide a clean, readable syntax for defining CLI options, reducing boilerplate compared to native PHP functions.
Closures can be attached directly to options using `must()` and `map()` methods, enabling inline validation and transformation without extra code, as shown in the example with title validation.
Generates user-friendly help pages based on option definitions, accessible via a default `--help` flag, making scripts self-documenting with minimal effort.
Provides formatted error messages for invalid input and allows trapping errors or throwing exceptions via `doNotTrapErrors()`, improving debuggability and user experience.
The library lacks built-in functionality for handling sub-commands, which is essential for complex CLI tools like version control systems or multi-command utilities.
Installation is exclusively through Composer, as stated in the README, which can be a barrier for projects that avoid package managers or require manual inclusion.
Requires PHP 8.1 or higher, limiting its use in older environments and potentially causing migration issues for legacy codebases, as noted in the change log.