Centum\Console
The Console component makes it easy to develop command line applications in Centum.
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.
Constructor
Centum\Console\Application(
Centum\Interfaces\Container\ContainerInterface $container
);
getCommandMetadata(class-string<Centum\Interfaces\Console\CommandInterface> $commandClass): Centum\Console\CommandMetadataRetrieve metadata for a command.addCommand(class-string<Centum\Interfaces\Console\CommandInterface> $commandClass): voidRegister a new command.getCommands(): array<string, class-string<Centum\Interfaces\Console\CommandInterface>>List all registered commands.addExceptionHandler(class-string<Centum\Interfaces\Console\ExceptionHandlerInterface> $exceptionClass): voidRegister an exception handler for console errors.handle(Centum\Interfaces\Console\TerminalInterface $terminal): intRun the console application.
Default Commands
The following code snippets assume that the console application will be stored in bin/console.
ListCommand
Will list all registered Centum\Console\Command objects:
php bin/console list
QueueConsumeCommand
Will take the next available Task from the Queue and consume it (see Queue docs):
php bin/console queue:consume