Dealing with inputs

Making practical and useful commands usually requires the ability to pass on the dynamic information from the operating system console to our application command. The Console component differentiates two types of inputs--arguments and options:

  • Arguments are ordered, space-separated (John Doe), optional or required, string types of information. Assignment of arguments comes after the command name itself. We use the addArgument() method of the Symfony\Component\Console\Command\Command instance to assign arguments to our custom command.
  • Options are unordered, two-dashes-separated (--name=John --surname=Doe), always optional, assigned type of information. The assignment of options comes after the command name itself. We use ...

Get Mastering PHP 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.