setName('examplecommand:helloworld'); $this->setDescription('ExampleCommandDescription'); $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:'); } /** * The actual task is defined in this method. Here you can access any option or argument that was defined on the * command line via $input and write anything to the console via $output argument. * In case anything went wrong during the execution you should throw an exception to make sure the user will get a * useful error message and to make sure the command does not exit with the status code 0. * * Ideally, the actual command is quite short as it acts like a controller. It should only receive the input values, * execute the task by calling a method of another class and output any useful information. * * Execute the command like: ./console examplecommand:helloworld --name="The Piwik Team" */ protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getOption('name'); $message = sprintf('HelloWorld: %s', $name); $output->writeln($message); } }