clue/commander
Minimal, pragmatic console framework for PHP. Define commands with arguments/options, get automatic help/usage output, and run apps via a simple dispatcher. Lightweight alternative to Symfony Console for building small CLI tools quickly.
clue/commander is a lightweight library for parsing command-line arguments and matching them against defined command structures in PHP. Start by installing via Composer:
composer require clue/commander
The first use case is typically building a CLI tool: define your command tree using Command objects with positional arguments, flags, and options. The parser automatically validates and extracts inputs, making it ideal for simple scripts or micro-CLIs where full frameworks like Symfony Console would be overkill.
Use Command::create() to build nested command hierarchies:
$cmd = Command::create('app', Command::create('run',
Argument::required('file'),
Option::flag('debug'),
Option::value('env', 'production')
));
Parse inputs with Parser::parse($argv, $cmd), which returns structured data (command path, args, flags, options). Workflows commonly involve:
service migrate, service seed).clue/path-match for route-like command matching, or with clue/commander-react for async command handling.Option::flag()) require explicit true/false handling in logic, unlike Symfony’s addOption(..., InputOption::VALUE_NONE).--User-Name) may cause issues; normalize names to --user-name in Option definitions.Command for custom behavior (e.g., automatic help generation, version flags).Parser::setTrace(true) and inspecting the internal match trace.How can I help you explore Laravel packages today?