switon / cli
Command surface with discovery, option binding, help output, and shell completion for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- psr/container: ^2.0
- psr/event-dispatcher: ^1.0
- switon/binding: ^1.0
- switon/command: ^1.0
- switon/console: ^1.0
- switon/core: ^1.0
- switon/event: ^1.0
- switon/invoker: ^1.0
- switon/kernel: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Switon's CLI runtime for auto-discovered commands, help, and shell completion.
Highlights
- Auto-discovered commands: package and app commands appear without manual registration.
- Multi-action commands: one command can expose several actions with shared help.
- Automatic options: action parameters become long options by default, with
#[ShortOption]for short aliases. - Inline help text: command help stays close to the code.
- Shell completion: the same command metadata feeds bash and zsh completion.
Installation
composer require switon/cli
Quick Start
use Switon\Core\Attribute\Autowired; use Switon\Core\ConsoleInterface; /** * Send a greeting. */ class GreetCommand { #[Autowired] protected ConsoleInterface $console; /** * Say hello to one user. * * @param string $name Recipient name. * @param bool $shout Uppercase the message. */ public function helloAction(string $name = 'world', bool $shout = false): void { $message = $shout ? 'HELLO, {name}!' : 'Hello, {name}!'; $this->console->success($message, ['name' => $name]); } }
bash bin/console greet:hello --name=world --shout
Docs: https://docs.switon.dev/latest/cli
License
MIT.