AddUserCommand
class AddUserCommand extends Command (View source)
A console command that creates users and stores them in the database.
To use this command, open a terminal window, enter into your project directory and execute the following:
$ php bin/console app:add-user
To output detailed information, increase the command verbosity:
$ php bin/console app:add-user -vv
See https://symfony.com/doc/current/cookbook/console/console_command.html For more advanced uses, commands can be defined as services too. See https://symfony.com/doc/current/console/commands_as_services.html
Properties
static protected | $defaultName | to make your command lazily loaded, configure the $defaultName static property, so it will be instantiated only when the command is actually called. |
Methods
No description
{@inheritdoc}
This optional method is the first one executed for a command after configure() and is useful to initialize properties based on the input arguments and options.
This method is executed after initialize() and before execute(). Its purpose is to check if some of the options/arguments are missing and interactively ask the user for those values.
This method is executed after interact() and initialize(). It usually contains the logic to execute to complete this command task.
Details
__construct(EntityManagerInterface $em, UserPasswordEncoderInterface $encoder, ValidatorInterface $validator)
protected void
configure()
{@inheritdoc}
protected void
initialize(InputInterface $input, OutputInterface $output)
This optional method is the first one executed for a command after configure() and is useful to initialize properties based on the input arguments and options.
protected void
interact(InputInterface $input, OutputInterface $output)
This method is executed after initialize() and before execute(). Its purpose is to check if some of the options/arguments are missing and interactively ask the user for those values.
This method is completely optional. If you are developing an internal console command, you probably should not implement this method because it requires quite a lot of work. However, if the command is meant to be used by external users, this method is a nice way to fall back and prevent errors.
protected int
execute(InputInterface $input, OutputInterface $output)
This method is executed after interact() and initialize(). It usually contains the logic to execute to complete this command task.