Weave 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

Commander Laravel Package

adamgoose/commander

Commander brings a clean, expressive API to Laravel for organising console logic into reusable, testable pieces, helping you keep Artisan commands tidy and your application's CLI maintainable as it grows.

View on GitHub
Deep Wiki
Context7

Commands and Domain Events

Frequently asked questions about Commander
What is adamgoose/commander and what problem does it solve?
Commander is a Laravel package that implements the command bus pattern, letting you move application logic out of bloated controllers and into dedicated command classes. Each command is self-handling and resolved through Laravel's service container, so dispatching one is a single expressive call from anywhere in your app. It adds queue support, dependency injection, and a middleware pipeline on top of that structure.
How do I install Commander in a Laravel application?
Install it with Composer using composer require adamgoose/commander. As a Laravel package it uses package auto-discovery, so the service provider is registered without manual edits to your config files. Once installed you can create your first command class and dispatch it from a controller, job, listener, or Artisan command.
Do I have to register a handler for every command manually?
No. Commander commands are self-handling, and handlers are resolved automatically through Laravel's container. You do not need to write container bindings for each command in a service provider. That means adding a new command is usually just a matter of creating one class.
Can Commander commands be queued and run asynchronously?
Yes, Commander includes queue support so a command can be pushed onto a queue and processed by a worker instead of running in the request cycle. This is useful for slow or side-effect-heavy work like sending notifications or syncing third-party data. The dispatch API stays the same whether execution is synchronous or queued.
How does dependency injection work inside Commander command handlers?
Dependencies are resolved from Laravel's service container, so you can type-hint the services, repositories, or config objects a handler needs and they will be injected for you. This keeps handlers testable because you can swap implementations through the container. It also means you avoid instantiating collaborators by hand inside your business logic.
What is the middleware pipeline in Commander used for?
Middleware lets you wrap command execution with cross-cutting concerns such as logging, authorization checks, validation, or database transactions. Instead of repeating that code in every handler, you attach it once and it runs around the command. This keeps handlers focused on the actual business operation.
Which Laravel versions does Commander support?
Commander is built directly on Laravel's container and queue components, so it targets modern Laravel releases. Because the supported range can change between releases, check the illuminate/support constraint in the package's composer.json or on its Packagist page before installing. Do this specifically before upgrading to a new Laravel major version.
How do I test Commander commands in Laravel?
Commands are plain classes, so you can instantiate one and invoke it directly in a unit test, asserting on the result or on the state it changes. For integration coverage, dispatch the command inside your normal Laravel test and assert the observable side effects. When a command is queued, use Laravel's queue fakes so the test does not rely on a running worker.
Where can I dispatch a Commander command from?
From anywhere in your application: controllers, event listeners, queued jobs, scheduled tasks, and Artisan commands. The point of the pattern is that the command wraps the reusable piece of business logic, and every entry point calls it the same way. This avoids duplicating logic across HTTP and CLI contexts.
Is Commander actively maintained and safe to use in production?
Check the GitHub repository for recent commits, tagged releases, and open issues before adopting it, since maintenance activity is the best signal of long-term support. The package is a thin layer over Laravel's own container and queue systems, so the underlying risk is relatively low. Still, pin a specific version in composer.json and run your test suite after any upgrade.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console