Skip to content

switon-php/cli

Repository files navigation

Switon CLI Package

CI PHP 8.3+

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.

About

Command surface with discovery, option binding, help output, and shell completion for Switon Framework

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages