Parsing command line parameters
The recipe Building and running a shell showed us how to create a shell that adds records based on user-provided information. This recipe adds support to import accounts from a CSV file, while allowing the user to configure different settings through the use of command-line parameters.
Getting ready
To go through this recipe we need the user shell implemented. Follow the entire recipe Building and running a shell.
We will also need a sample CSV file from which to import records. Create a file named users.csv
and place it in a directory of your choice (for example, in the application's app/tmp
directory) with the following contents:
"john","John","Doe" "jane","Jane","Doe" "mark","Mark","Doe" "mathew","Mathew","Doe" "peter","Peter","Doe" "roland","Roland","Doe"
How to do it...
1. Edit your
app/vendors/shells/user.php
file, and change the name of the methodmain()
toadd()
.2. Add the following method right below the
add()
method:public function help() { $this...