Sets the description for the command.
public setDescription ( string $description ) : |
||
$description | string | The description for the command |
return | The current instance |
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class HelloWorldCommand extends Command { protected function configure() { $this ->setName('hello-world') ->setDescription('Prints "Hello, World!" to the console') ; } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Hello, World!'); } }
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class GreetCommand extends Command { protected function configure() { $this ->setName('greet') ->setDescription('Greets a person by name') ->addArgument('name', InputArgument::REQUIRED, 'The name of the person to greet.') ; } protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $output->writeln(sprintf('Hello, %s!', $name)); } }In this example, the `setDescription` method is again used to add a description of the command "greet". Overall, the Symfony\Component\Console\Command package library provides a set of classes that help developers create command-line applications in PHP. The setDescription method is just one of the many tools available in this package.
public setDescription ( string $description ) : |
||
$description | string | The description for the command |
return | The current instance |