Creating CLI commands
Yii has good command-line support and allows creating reusable console commands. Console commands are faster to create than web GUIs. If you need to create some kind of utility for your application that will be used by developers or administrators, console commands are the right tool.
To show how to create a console command, we'll create a simple command that will clean up various things, such as assets and temp directories.
Create a new
yii2-app-basic application using the composer, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
How to do it…
Carry out the following steps to create CLI commands:
- Create the
commands/CleanController.phpfile with the following ...