Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Console Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Lazy command loading: Use 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).
  • Event-driven controls: Attach listeners for 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.
  • Command subclassing: Extend AbstractCommand and override doExecute() to access $options (parsed CLI arguments/flags). Use addArgument()/addOption() in configure() with explicit defaults to avoid runtime null warnings.
  • Testing: Inject mocks for $options array in unit tests or use $application->run() with captured stdout/stderr in integration tests — no need to mock Symfony-style input objects.

Gotchas and Tips

  • Strict PHP version enforcement: Version 4.x requires PHP 8.3+; older versions won’t satisfy ^4.0 constraints — verify php -v and adjust constraints accordingly.
  • No auto-discovery: Unlike Symfony Flex, the package does not auto-register commands ending in 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.
  • Container loader caveats: Services in the mapping must be callables returning AbstractCommand instances. Registering raw class strings or concrete objects (e.g., ['deploy' => DeployCommand::class]) fails silently — use fn() => new DeployCommand.
  • Event listener typing: Listeners must anticipate typed events (e.g., ApplicationErrorEvent). Mistyping (e.g., expecting Throwable directly) breaks listeners — always type-hint the correct event class.
  • Joomla ecosystem lock-in: This package integrates tightly with joomla/di, joomla/event, and Joomla’s coding standards — avoid it for non-Joomla projects where Symfony Console is lighter and better supported.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport