joomla/console
Joomla Framework Console provides the infrastructure for building PHP command-line applications. It offers a base Application, command routing, input/output handling, and helpers to create structured CLI tools and workflows using composer-installed components.
Install via Composer with composer require joomla/console "^4.0" (PHP 8.3+ required per latest release). Begin by creating a minimal CLI bootstrap — instantiate Joomla\Console\Application, register at least one AbstractCommand subclass, and call execute(). Unlike Symfony Console, commands extend AbstractCommand and implement configure() and doExecute(array $options): int. Output is accessed via $this->getApplication()->getConsoleOutput() rather than direct InputInterface/OutputInterface parameters — this is the first conceptual shift for Symfony veterans.
ContainerLoader with a PSR-11 container (e.g., Joomla\DI\Container) to defer command instantiation. Map command names (e.g., 'migrate') to container service IDs (e.g., 'app.command.migrate') and register the loader via $application->setCommandLoader($loader).ConsoleEvents::COMMAND_ERROR, APPLICATION_ERROR, or TERMINATE to centralize error handling, metrics, or cleanup (e.g., cache flush after deployment). Events carry typed payloads — e.g., ApplicationErrorEvent — enabling clean decoupling.AbstractCommand and override doExecute() to access $options (parsed CLI arguments/flags). Use addArgument()/addOption() in configure() with explicit defaults to avoid runtime null warnings.$options array in unit tests or use $application->run() with captured stdout/stderr in integration tests — no need to mock Symfony-style input objects.^4.0 constraints — verify php -v and adjust constraints accordingly.Command. You must manually addCommand(), register via ContainerLoader, or extend Application to implement discovery logic.$options vs input/output: doExecute() receives an associative array of parsed input — not InputInterface/OutputInterface. To render output, rely on $this->getApplication()->getConsoleOutput(); for input parsing, check $options['verbose'] ?? false.AbstractCommand instances. Registering raw class strings or concrete objects (e.g., ['deploy' => DeployCommand::class]) fails silently — use fn() => new DeployCommand.ApplicationErrorEvent). Mistyping (e.g., expecting Throwable directly) breaks listeners — always type-hint the correct event class.joomla/di, joomla/event, and Joomla’s coding standards — avoid it for non-Joomla projects where Symfony Console is lighter and better supported.How can I help you explore Laravel packages today?