Google News
logo
Phalcon - Interview Questions
What about CLI in Phalcon?
CLI stands for Command Line Interface. CLI applications are executed from the command line or a shell prompt. One of the benefits of CLI applications is that they do not have a view layer (only potentially echoing output on screen) and can be run more than one at a time. Some of the common usages are cron job tasks, manipulation scripts, import data scripts, command utilities and more.
 
Structure : You can create a CLI application in Phalcon, using the Phalcon\Cli\Console class. This class extends from the main abstract application class, and uses a directory in which the Task scripts are located. Task scripts are classes that extend Phalcon\Cli\Task and contain the code that we need executed.
 
The directory structure of a CLI application can look like this :
src/tasks/MainTask.php
php cli.php
In the above example, the cli.php is the entry point of our application, while the src/tasks directory contains all the task classes that handle each command.
Advertisement