One benefit of using shells in CakePHP is to handle process-intensive tasks, which take a long time to run. In this recipe, we'll create a CakePHP console shell to deal with a mass CSV data import. We'll process a data file and import all rows, while logging import errors to another file.
As this is the only task in our shell, we're not using
Task this time.
First, if you don't have it already, create the
packages database table using the following SQL statement:
CREATE TABLE packages ( id INT NOT NULL AUTO_INCREMENT, recipient VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, created DATETIME, modified DATETIME, PRIMARY KEY(id) );
Then, create the associated model in a file named
app/Model/ with the following ...