nategood/commando
Commando is a lightweight PHP library for building command-line apps: define options and arguments, parse input, generate help text, and validate values. Ideal for quick CLI tools and scripts with minimal boilerplate.
Start by installing via Composer: composer require nategood/commando. The library provides a simple, fluent API for building CLI tools—ideal for quick scripts or small Symphony/ Laravel-style console commands. Begin by extending the Commando\Command class or using the Command factory to define arguments and options. The first use case is typically parsing user input for a script: e.g., php myscript.php --name=John --verbose becomes accessible as $command->getArgument('name') and $command->getOption('verbose'). Check the examples/ folder in the repo for minimal working demos.
Command::create() to bootstrap a command inline:
$command = Command::create()
->addArgument('name', Command::REQUIRED)
->addOption('env', 'dev');
$name = $command->getArgument('name');
addArgument(), addOption(), and setHelp() for clean, readable command definitions.addArgument(..., Command::OPTIONAL, 'default', 'int') to enable built-in type casting and validation.Commando\Command.exit() automatically—you must explicitly return or exit() after handling command logic. Forgetting this causes silent script hangs or double execution.--Verbose ≠ --verbose). Normalize user input in CLI tools if case-insensitivity is expected.--foo bar baz vs bar --foo baz). Always place positional args at the end.--verbose), getOption() returns true, but misusing getValue() may throw exceptions—prefer hasOption() + getOption().execute() in a subclass to centralize logic, or hook into onParseError() for custom error messages.How can I help you explore Laravel packages today?