Library for Symfony console commands
composer require vanengers/symfony-console-command-lib
class MyCommand extends AbstractConsoleCommand {}
Implement the abstract methods and you are good to go.
the method that actually executes the command, do not use the execute() method from the parent class
this should return the name of the command for the command line
this should return a description of the command for the command line
this should return an array of options for the command line Each Option will be checked for default value and value inputed by the user Look at the example
only simple types are expected: array, bool, int, string
You could implicitly require an input by setting the default value to null and setting the required flag to true
You can add validators to the Option in getOptions
new Option('config', 'name param', 'string', null, true, null, [
new FileExistsValidator(),
])
By setting default value to null and required to true, you can require a file that exists. Settting up validators is easy, just create a class that implements the IParamValidate interface and add it to the option.