Creating a console controller

A console controller is totally similar to the web controllers that we created earlier. It extends the \yii\console\Controller base class and can return an integer value indicating the status response of the action (0 stands for successful execution of the action), also named exit code.

The public properties of the controller can be made available as an option only if their names are returned by the options() method that accepts actionID as the parameter; so the response can be customized according to actionID.

The response of the options() method is an array of text string that represents the public property names of the controller.

Starting from the advanced template application that we previously installed in the ...

Get Yii2 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.