Console API
CakePHP provides a rich console API to let you create and reuse specific project tasks that are more suited to being executed in a console environment. Keep in mind that when running commands from shell, you're not restricted by the same limitations the web server typically puts on server resources such as memory use and execution time. You can also have a less restrictive PHP configuration for your CLI environment, allow additional PHP extensions, and do more.
In this recipe, we'll create a new console shell and task to explore some of the features of the console shell API. Note that we'll be using a shell named PdfShell
as an example, but no real PDF generation will happen.
How to do it...
Perform the following steps:
First, update our existing file named
PdfShell.php
inapp/Console/Command/
with the following content:<?php App::uses('AppShell', 'Console/Command'); class PdfShell extends AppShell { public $tasks = array('Generate'); public function main() { $this...