yii2 is not showing the CRUD created

when creating from gii a CRUD from a table with multiple foreign key and when i try to access via the normal way without pretty url, it’s giving me a 404 error… for this application i’ve built 6 CRUD already (some has its own trouble), but i cannnot figure out what’s going on here…

i create the crud for the first tables…

Generating code using template "C:\Bitnami\wampstack-5.6.30-1\apache2\htdocs\mysoftware\vendor\yiisoft\yii2-gii\generators\crud/default"…

generated controllers\SeguridadUP2newController.php

generated views\seguridad-up2new\_form.php

generated views\seguridad-up2new\create.php

generated views\seguridad-up2new\index.php

generated views\seguridad-up2new\update.php

generated views\seguridad-up2new\view.php

done!

this is what web gii gave me or throws me…

at last i try to access

mysoftware/frontend/web/index.php?r=seguridad-up2new

and it’s giving me a 404 error

the table has a many to many relationship with 3 another one…

this is the model…

<?php

namespace frontend\models;

use Yii;

/**

  • This is the model class for table "seguridad_usuarios_programas_privilegios".

  • @property integer $idusuarios_programas_privilegios

  • @property integer $idusuario

  • @property integer $idprograma

  • @property integer $idprivilegio

  • @property SeguridadPrivilegios $idprivilegio0

  • @property SeguridadProgramas $idprograma0

  • @property SeguridadUsuarios $idusuario0

*/

class SeguridadUPPModel extends \yii\db\ActiveRecord

{

/**


 * @inheritdoc


 */


public static function tableName()


{


    return 'seguridad_usuarios_programas_privilegios';


}





/**


 * @inheritdoc


 */


public function rules()


{


    return [


        [['idusuarios_programas_privilegios'], 'required'],


        [['idusuarios_programas_privilegios', 'idusuario', 'idprograma', 'idprivilegio'], 'integer'],


        [['idprivilegio'], 'exist', 'skipOnError' =&gt; true, 'targetClass' =&gt; SeguridadPrivilegiosModel::className(), 'targetAttribute' =&gt; ['idprivilegio' =&gt; 'idprivilegio']],


        [['idprograma'], 'exist', 'skipOnError' =&gt; true, 'targetClass' =&gt; SeguridadProgramasModel::className(), 'targetAttribute' =&gt; ['idprograma' =&gt; 'idprograma']],


        [['idusuario'], 'exist', 'skipOnError' =&gt; true, 'targetClass' =&gt; SeguridadUsuariosModel::className(), 'targetAttribute' =&gt; ['idusuario' =&gt; 'idusuario']],


    ];


}





/**


 * @inheritdoc


 */


public function attributeLabels()


{


    return [


        'idusuarios_programas_privilegios' =&gt; 'Idusuarios Programas Privilegios',


        'idusuario' =&gt; 'Idusuario',


        'idprograma' =&gt; 'Idprograma',


        'idprivilegio' =&gt; 'Idprivilegio',


    ];


}





/**


 * @return &#092;yii&#092;db&#092;ActiveQuery


 */


public function getIdprivilegio0()


{


    return &#036;this-&gt;hasOne(SeguridadPrivilegiosModel::className(), ['idprivilegio' =&gt; 'idprivilegio']);


}





/**


 * @return &#092;yii&#092;db&#092;ActiveQuery


 */


public function getIdprograma0()


{


    return &#036;this-&gt;hasOne(SeguridadProgramasModel::className(), ['idprograma' =&gt; 'idprograma']);


}





/**


 * @return &#092;yii&#092;db&#092;ActiveQuery


 */


public function getIdusuario0()


{


    return &#036;this-&gt;hasOne(SeguridadUsuariosModel::className(), ['idusuario' =&gt; 'idusuario']);


}

}

and this is the controller…

<?php

namespace frontend\controllers;

use Yii;

use frontend\models\SeguridadUPPModel;

use yii\data\ActiveDataProvider;

use yii\web\Controller;

use yii\web\NotFoundHttpException;

use yii\filters\VerbFilter;

/**

  • SeguridadUPPController implements the CRUD actions for SeguridadUPPModel model.

*/

class SeguridadUPPController extends Controller

{

/**


 * @inheritdoc


 */


public function behaviors()


{


    return [


        'verbs' =&gt; [


            'class' =&gt; VerbFilter::className(),


            'actions' =&gt; [


                'delete' =&gt; ['POST'],


            ],


        ],


    ];


}





/**


 * Lists all SeguridadUPPModel models.


 * @return mixed


 */


public function actionIndex()


{


    &#036;dataProvider = new ActiveDataProvider([


        'query' =&gt; SeguridadUPPModel::find(),


    ]);





    return &#036;this-&gt;render('index', [


        'dataProvider' =&gt; &#036;dataProvider,


    ]);


}





/**


 * Displays a single SeguridadUPPModel model.


 * @param integer &#036;id


 * @return mixed


 */


public function actionView(&#036;id)


{


    return &#036;this-&gt;render('view', [


        'model' =&gt; &#036;this-&gt;findModel(&#036;id),


    ]);


}





/**


 * Creates a new SeguridadUPPModel model.


 * If creation is successful, the browser will be redirected to the 'view' page.


 * @return mixed


 */


public function actionCreate()


{


    &#036;model = new SeguridadUPPModel();





    if (&#036;model-&gt;load(Yii::&#036;app-&gt;request-&gt;post()) &amp;&amp; &#036;model-&gt;save()) {


        return &#036;this-&gt;redirect(['view', 'id' =&gt; &#036;model-&gt;idusuarios_programas_privilegios]);


    } else {


        return &#036;this-&gt;render('create', [


            'model' =&gt; &#036;model,


        ]);


    }


}





/**


 * Updates an existing SeguridadUPPModel model.


 * If update is successful, the browser will be redirected to the 'view' page.


 * @param integer &#036;id


 * @return mixed


 */


public function actionUpdate(&#036;id)


{


    &#036;model = &#036;this-&gt;findModel(&#036;id);





    if (&#036;model-&gt;load(Yii::&#036;app-&gt;request-&gt;post()) &amp;&amp; &#036;model-&gt;save()) {


        return &#036;this-&gt;redirect(['view', 'id' =&gt; &#036;model-&gt;idusuarios_programas_privilegios]);


    } else {


        return &#036;this-&gt;render('update', [


            'model' =&gt; &#036;model,


        ]);


    }


}





/**


 * Deletes an existing SeguridadUPPModel model.


 * If deletion is successful, the browser will be redirected to the 'index' page.


 * @param integer &#036;id


 * @return mixed


 */


public function actionDelete(&#036;id)


{


    &#036;this-&gt;findModel(&#036;id)-&gt;delete();





    return &#036;this-&gt;redirect(['index']);


}





/**


 * Finds the SeguridadUPPModel model based on its primary key value.


 * If the model is not found, a 404 HTTP exception will be thrown.


 * @param integer &#036;id


 * @return SeguridadUPPModel the loaded model


 * @throws NotFoundHttpException if the model cannot be found


 */


protected function findModel(&#036;id)


{


    if ((&#036;model = SeguridadUPPModel::findOne(&#036;id)) &#33;== null) {


        return &#036;model;


    } else {


        throw new NotFoundHttpException('The requested page does not exist.');


    }


}

}

i’m using a bitnami 64 bit machine with mysql in windows…

also i got the source code from composer

and i executed the init command first… and also migrate command which gave me access to login logout and signup…

FYI i can access without no problem others CRUD… and they’re created well i mean i have to battle with the thing of frontend common and backend…

i’m sure it’s a problem with the code…

Your url

Doesn’t seem to match the controller name:




 class SeguridadUPPController extends Controller



Assuming you mean this one:




 generated controllers\SeguridadUP2newController.php



Your route would be




 mysoftware/frontend/web/index.php?r=seguridad-u-p2new



Uppercase letters are turned into hyphen + lowercase:

http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html#controller-class-naming

so much thanks for replying me… surprising and for my impression when i try to access your url i’ve got an error at least… (not getting the simple 404 not found messsage) instead the yii exception general class is telling me it’s not finding some file… i’ll paste the code and a printscreen

View not Found – yii\base\ViewNotFoundException

The view file does not exist: C:\Bitnami\wampstack-5.6.30-1\apache2\htdocs\mysoftware\frontend\views\seguridad-u-p2new\index.php

1. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;View.php at line 229


220221222223224225226227228229230231232233234235236237238





    {


        &#036;viewFile = Yii::getAlias(&#036;viewFile);


 


        if (&#036;this-&gt;theme &#33;== null) {


            &#036;viewFile = &#036;this-&gt;theme-&gt;applyTo(&#036;viewFile);


        }


        if (is_file(&#036;viewFile)) {


            &#036;viewFile = FileHelper::localize(&#036;viewFile);


        } else {


            throw new ViewNotFoundException(&quot;The view file does not exist: &#036;viewFile&quot;);


        }


 


        &#036;oldContext = &#036;this-&gt;context;


        if (&#036;context &#33;== null) {


            &#036;this-&gt;context = &#036;context;


        }


        &#036;output = '';


        &#036;this-&gt;_viewFiles[] = &#036;viewFile;


 





2. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;View.php at line 152 – yii&#092;base&#092;View::renderFile('C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;ap...', ['dataProvider' =&gt; yii&#092;data&#092;ActiveDataProvider], frontend&#092;controllers&#092;SeguridadUP2newController)


3. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;Controller.php at line 381 – yii&#092;base&#092;View::render('index', ['dataProvider' =&gt; yii&#092;data&#092;ActiveDataProvider], frontend&#092;controllers&#092;SeguridadUP2newController)


4. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;frontend&#092;controllers&#092;SeguridadUP2newController.php at line 44 – yii&#092;base&#092;Controller::render('index', ['dataProvider' =&gt; yii&#092;data&#092;ActiveDataProvider])


38394041424344454647484950





        &#036;dataProvider = new ActiveDataProvider([


            'query' =&gt; SeguridadUPPModel::find(),


        ]);


 


        return &#036;this-&gt;render('index', [


            'dataProvider' =&gt; &#036;dataProvider,


        ]);


    }


 


    /**


     * Displays a single SeguridadUPPModel model.


     * @param integer &#036;id


     * @return mixed





5. frontend&#092;controllers&#092;SeguridadUP2newController::actionIndex()


6. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;InlineAction.php at line 57 – call_user_func_array([frontend&#092;controllers&#092;SeguridadUP2newController, 'actionIndex'], [])


7. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;Controller.php at line 156 – yii&#092;base&#092;InlineAction::runWithParams(['r' =&gt; 'seguridad-u-p2new'])


8. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;Module.php at line 523 – yii&#092;base&#092;Controller::runAction('', ['r' =&gt; 'seguridad-u-p2new'])


9. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;web&#092;Application.php at line 102 – yii&#092;base&#092;Module::runAction('seguridad-u-p2new', ['r' =&gt; 'seguridad-u-p2new'])


10. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;vendor&#092;yiisoft&#092;yii2&#092;base&#092;Application.php at line 380 – yii&#092;web&#092;Application::handleRequest(yii&#092;web&#092;Request)


11. in C:&#092;Bitnami&#092;wampstack-5.6.30-1&#092;apache2&#092;htdocs&#092;mysoftware&#092;frontend&#092;web&#092;index.php at line 17 – yii&#092;base&#092;Application::run()


11121314151617





    require(__DIR__ . '/&#46;&#46;/&#46;&#46;/common/config/main.php'),


    require(__DIR__ . '/&#46;&#46;/&#46;&#46;/common/config/main-local.php'),


    require(__DIR__ . '/&#46;&#46;/config/main.php'),


    require(__DIR__ . '/&#46;&#46;/config/main-local.php')


);


 


(new yii&#092;web&#092;Application(&#036;config))-&gt;run();

$_GET = [

'r' =&gt; 'seguridad-u-p2new',

];

Yii Framework

2017-02-23, 04:46:29

Apache

Yii Framework/2.0.11.2

Error message:

Why not just create the missing view, then?

Yii 2 tells exactly what view it did not find.

So, either make sure that the directory has the correct name - it hasn’t - or rename your controller.

Also, two forum tips:

  1. Do not quote entire posts, when it is not needed. It makes it really difficult to read (lots of scrolling…)

  2. Use code tags: when you post any code, put it in code tags. (It’s the second last button).

thanks… it’s not my first time using this type of forum i’ve already used the extjs one a long long time ago back in 2010 which now is sencha. But i’s been a while i really havent posted this type of question due that most of the answer had the partner just at my right or near by me…

but with yii2 everything changed… even with the greatness of composer which is a great great tool, just right the tyoe of aptitude in debian like systems… i started hated 2 years ago but right now totally different…

just dont be mad but really i’ve choosed yii because it was great… right now i dont know what to say, i’m like new even i’ve used it for a project for a laaarge project but it was yii 1… i choosed yii2 because it’s supposed to be better than always, in the past was quite less complicated and more powerful i think…

i have one more question, i just want to use angularjs instead of extjs (despecting the fact i’m an extjs experienced programmer…), how do you recommend me adding angular? through composer?, i’ve just read a manual but they’re using angular 1 my intention is to use angular 2… i really dont like the messy url yii2 creates…

with angular i dont have to worry about it… but i’ve not used angularjs2 in the past. What i’ve used is bootstrap and so on.

In your opinion is AngularJS2 better than anything?

Personally, I am leaning towards Vue.js more than Angular 2, but you can use everything with Yii 2

I would advise you to search around for Yii 2 projects using Angular2, as far as I know there are several.

There is also a new Vue.js Yii 2 project.

Check the Extensions and the Yii Feed

Google and Github search also recommended, and Packagist.

Now, your original question:

Also, two options:

  1. Rename controller.

OR

  1. Rename view directory to ‘seguridad-u-p2new’

thanks for quick answer jacmoe… i was searching a little bit about vue.js but it’s quite new also…

the problem was fixed alone… in the github issue tracking i found that when GII is going to search for the table model thare was issues, hopefully and thanks to God, i could solve this. I just created a new model completely new… and it seems that the previusly crud that relies on it doesnt work well also… so i dig into the CRUD generator and created a new one… but the strange thing is that i did this twice and even three times…

I just created again for the fourth time the model class… it must be an issue when creating the first second and third one… we’ll keep in communication about VUE

i decided to keep on AngularJS 2. Vue seems to be easy to learn and to deploy… for A

Excellent!

Glad that you got it sorted.