Search code examples
crudyii2scaffolding

Yii2 "Page not found" when using CRUD generator


I have succesfully used Yii2 Model & CRUD Generators to obtain some skeleton code files for my web app. Particularly, the CRUD Generator claims to have succesfully created its view files into:

<yii_root>/basic/views/<my_view_name>/*.php

which I got by leaving "View Path" field blank.

However, browsing to:

https://<my_site_FQDN>/basic/web/index.php?r=<my_view_name>/index

spits a "Not Found (#404)" error and I'm unable to find any useful info in the Yii2 debug logs.

Any idea on this matter shall be welcome.

Antonio


Solution

  • <my_view_name> this is a terrible way of looking at this. Read about MVC.

    You are creating controllers, routes are to controllers not to views. Stop looking if the views are there... look if the controller is there. You never interact with a view, you always do with a controller. So, is your controller there? are you sure you have created it?

    Also what is the controller name? if you have something like ProductCategory then the correct route is

    https://<my_site_FQDN>/basic/web/index.php?r=product-category/index
    

    and not

    https://<my_site_FQDN>/basic/web/index.php?r=ProductCategory/index 
    

    Edit
    Ok, I see your problem, stop putting folders under other folders and so on. You created your CRUD wrong. Your controller has to be directly under controllers not under controllers/bibliografia, the same goes for the model. Delete the files and start again with CRUD as probably your namespaces are also wrong.