The Console component can be used to easily develop command line applications.

Application endpoints are treated as Centum\Console\Command objects. These Commands contain all of the code and all of the metadata is stored in a Centum\Console\CommandMetadata object.

Centum\Console\Application extracts the command name from $argv, finds the appropriate Command, and then executes the Command’s code.

Centum\Console\Application implements Centum\Interfaces\Console\ApplicationInterface.

    Centum\Interfaces\Container\ContainerInterface $container
  • public function getCommandMetadata(class-string<Centum\Interfaces\Console\CommandInterface> $commandClass): Centum\Console\CommandMetadata
  • public function addCommand(class-string<Centum\Interfaces\Console\CommandInterface> $commandClass): void
  • public function getCommands(): array<string, class-string<Centum\Interfaces\Console\CommandInterface>>
  • public function addExceptionHandler(class-string<Centum\Interfaces\Console\ExceptionHandlerInterface> $exceptionClass): void
  • public function handle(Centum\Interfaces\Console\TerminalInterface $terminal): int

Default Commands

The following code snippets assume that the console application will be stored in cli.php.


Will list all registered Centum\Console\Command objects:

php cli.php list


Will take the next available Task from the Queue and consume it (see Queue docs):

php cli.php queue:consume

Table of contents