protected function configure() { $this ->setName('mycommand') ->setDescription('This is my command') ->addArgument('arg1', InputArgument::REQUIRED, 'Argument 1') ->addArgument('arg2', InputArgument::OPTIONAL, 'Argument 2', 'default'); }
protected function execute(InputInterface $input, OutputInterface $output) { $arg1 = $input->getArgument('arg1'); $arg2 = $input->getArgument('arg2'); $output->writeln('Argument 1: ' . $arg1); $output->writeln('Argument 2: ' . $arg2); }
Argument 1: foo Argument 2: barOverall, the Symfony\Component\Console\Input\InputInterface package library provides a number of powerful tools for handling command-line input in PHP applications.