Using standalone actions
In Yii, you can define controller actions as separate classes and then connect them to your controllers. This will help you to reuse some common functionality.
For example, you can move the backend for autocomplete fields to an action and save some time by not having to write it over and over again.
Another example is that we can create all CRUD operations as separate standalone actions. We will write, create, view, and delete operations of the model and view the list operation of models.
Getting ready
- Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
- Let's create
post
table. Create migration for this using the ...
Get Yii2 Application Development Cookbook - Third Edition 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.