setName('reset') ->addOption('password', 'p', Option::VALUE_OPTIONAL, 'please enter the password you will set.') ->setDescription('the reset administrator password command'); } protected function execute(Input $input, Output $output) { if ($input->hasOption('password')) { $password = $input->getOption('password'); $password = $password ?: '123456'; } else { $password = '123456'; } LoginService::resetAdministratorPassword($password); // 指令输出 $output->writeln('password reset success'); } }