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

illuminate/console

Illuminate Console provides the Artisan command-line framework used by Laravel. Define commands, schedule tasks, manage input/output, prompts, and terminal styling, and integrate with the service container to build robust CLI tools and automation.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer: composer require illuminate/console. This package powers Laravel’s CLI (Artisan), but can be used standalone in any PHP project. To create your first command, extend Illuminate\Console\Command and implement the handle() method. Register commands in a Symfony\Component\Console\Application instance — use Application::setCommandName() to set the app name and add() to include commands. Run php your-script.php list to see available commands. The Laravel documentation’s Artisan section provides excellent reference examples, as this package is the core behind Artisan.

Implementation Patterns

  • Command Structure: Use configure() to set name, description, and arguments/options; handle() contains the logic; return self::SUCCESS or self::FAILURE.
  • Dependency Injection: Commands are resolved by Laravel’s container (if used) — type-hint dependencies in the constructor or use resolve().
  • Standalone Setup: In non-Laravel projects, bootstrap manually:
    $app = new Application('MyCLI', '1.0.0');
    $app->add(new MyCommand());
    $app->run();
    
  • Helper Methods: Leverage $this->info(), $this->error(), $this->ask(), $this->confirm() for user interaction and styled output.
  • Testing: Extend Tests\TestCase (if using Laravel) or use Symfony\Component\Console\Tester\CommandTester for unit testing commands.

Gotchas and Tips

  • Missing Container: In standalone use, features relying on Laravel’s service container (e.g., make(), inject() in handle()) won’t work unless you manually resolve dependencies or bootstrap the container.
  • Silent Mode: Use $this->laravel->instance('Illuminate\Console\Application', $this->getApplication()) if you need access to Laravel’s app bindings inside commands without full Laravel.
  • Hidden Commands: Set protected $hidden = true; to omit from the list output — useful for internal commands.
  • Prompt Issues in CI: Interactive methods (ask(), confirm()) fail in headless environments — guard with $this->input->isInteractive().
  • Extensibility: Override getHelperSet() for custom Symfony helpers, or extend Symfony\Component\Console\Input\InputDefinition to inject global options.
  • Autocompletion: Register with bash-completion via Application::registerCommandName() and provide completion commands (Artisan has this built-in; replicate manually if needed).
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