Skip to Content
Mastering PHP 7
book

Mastering PHP 7

by Branko Ajzele
June 2017
Intermediate to advanced
536 pages
9h 49m
English
Packt Publishing
Content preview from Mastering PHP 7

Creating a console command

Now that we have our barebone console application set up, let's create three commands to handle the following imaginary actions: 

  • Customer register
  • Customer status set
  • Customer export

The word imaginary simply flags that we will not actually concern ourselves with the inner details of the executed commands, as our focus is understanding how to reuse the Console component.

We start by creating CustomerRegisterCommand.php, CustomerStatusSetCommand.php, and CustomerExportCommand.php within our project's src/Foggyline/Console/Command/ directory.

 CustomerRegisterCommand.php file has the following content:

<?phpnamespace Foggyline\Console\Command;use Symfony\Component\Console\{  Command\Command, Input\InputInterface, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning PHP 7

Learning PHP 7

Antonio L Zapata (GBP)
Upgrading to PHP 5

Upgrading to PHP 5

Adam Trachtenberg

Publisher Resources

ISBN: 9781785882814Supplemental Content