zendframework/zend-console
Zend\Console provides a robust set of tools for building PHP command-line apps and scripts. It includes input parsing, argument and option handling, console adapters, and helpers for formatting output, making it easier to create interactive and portable CLI commands.
Zend\Console component, a standalone utility from the legacy Zend Framework for building CLI applications in PHP.composer require zendframework/zend-console) and look at Zend\Console\Console — the central facade with static methods like getColor(), getArgs(), getOptions(), and getEnv().$console = Zend\Console\Console::getInstance();
$opts = $console->getOptions(['name|n:s' => 'Your name']);
echo "Hello, {$opts['name']}!\n";
Zend\Console\Adapter\AdapterInterface to swap console adapters (e.g., for testing via Zend\Console\Adapter\Null) or integrate with Symfony’s Console for hybrid apps.Zend\Console\Getopt for structured argument parsing (especially if migrating older ZF code), which supports short/long flags, required/optional values, and help generation.Zend\Console\ColorInterface for portable colorized output:
echo Zend\Console\Console::colorize("Error!", Console::FG_RED) . PHP_EOL;
app.php user:create), manually define a router atop Getopt or pair it with Zend\Stdlib\Parameters for request-like parameter access.zendframework/* packages are unmaintained. For new work, migrate to laminas/laminas-console instead.Getopt parses all arguments as options unless getopt()-style spec strings are carefully defined (e.g., ['n:s' => 'name'], not ['n|name:s']).STDOUT to support ANSI (works by default on Windows 10+; older versions need \Composer\XdebugHandlers\XdebugHandler or ColorInterface::USE_ANSI disabled).Zend\Console\Console::isInteractive() to detect TTY and adapt output verbosity or fallback to plain text.Zend\Console\Adapter\Null or mock Console to avoid fwrite() side effects — but note static methods are hard to mock; prefer Console::getInstance() refactoring for DI.How can I help you explore Laravel packages today?