Creating Controller and views using Gii tool in Yii2
This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete) operations for the specified data model.
Click “start” button under CRUD generator to create Controller and Views for corresponding Model.
Here you should provide the fully qualified class name of already created Model.
Note : If your model was generated in backend, put backend instead of frontend.
Search Model Class
Here you can provide search model class.
Here you can provide controller class to be generated.
Click on the “Preview” button to view the file path and then click “Generate” button to generate files.
possible error: Class
'frontend\models\Products' does not exist or has syntax error.
namespace app\models to
namespace frontend\models or
Now your controller file is generated in
@app\frontend\controllers and view files are generated in
File structure will be like this
@app /frontend /controllers /ProductsController.php /models /Products.php /ProductsSearch.php /views /products /_form.php /_search.php /create.php /index.php /update.php /view.php
you can access create form through this link
you can access index page through this link
* app – your app name.
*products – your controller name.