Fatal error: Using $this when not in object context

I generated CRUD, but i am not able to view webpages. I am getting "Fatal error: Using $this when not in object context in C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\TCyii\advanced\backend\web\product\index.php on line 10".

Full application was generated using command:

composer create-project yiisoft/yii2-app-advanced advanced 2.0.3

I just added one table "tproducta" to database, generated model for it in backend folder and run CRUD. CRUD generated controller in backend\controllers folder and several *.php files in web\product folder including web\product\index.php

Finally i regenerated CRUD, leaving empty “View Path : ”

This created files in folder "views\tproducta" instead of "web\product", for instance

C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\TCyii\advanced\backend\views\tproducta\create.php

The error ""Fatal error: Using $this when not in object context"" have disappeared, but i am still not able to view CRUD. I am getting message instead :

"The requested URL /TCyii/advanced/backend/web/tproducta/ was not found on this server."

I try to view this index.php using url:

"http://localhost/TCyii/advanced/backend/web/Tproducta"

"http://localhost/TCyii/advanced/backend/web/Tproducta/"

"http://localhost/TCyii/advanced/backend/web/Tproducta/index.php"

Maybe i use wrong url?

C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\TCyii\advanced\backend\web\product\index.php


<?php


use yii\helpers\Html;

use yii\grid\GridView;




/* @var $this yii\web\View */

/* @var $searchModel backend\models\TproductaSearchModel */

/* @var $dataProvider yii\data\ActiveDataProvider */


$this->title = 'Tproductas';

$this->params['breadcrumbs'][] = $this->title;

?>

<div class="tproducta-index">


    <h1><?= Html::encode($this->title) ?></h1>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


    <p>

        <?= Html::a('Create Tproducta', ['create'], ['class' => 'btn btn-success']) ?>

    </p>


    <?= GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'columns' => [

            ['class' => 'yii\grid\SerialColumn'],


            'id',

            'website',

            'good_type',

            'good_kwd1',

            'good_kwd2',

            ['class' => 'yii\grid\ActionColumn'],

        ],

    ]); ?>


</div>

I found one solution in,

http://www.yiiframework.com/forum/index.php/topic/58327-solved-fatal-error-using-this-when-not-in-object/

but in my case namespaces are correct.

How to solve this?

First you have to generate CRUD leaving empty “View Path : ”

This creates view files in folder "views\tproducta" instead of "web\product", for instance

C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\TCyii\advanced\backend\views\tproducta\create.php

For generated CRUD access use url:

"http://localhost/TCyii/advanced/backend/web/index.php?r=tproducta"

"http://localhost/TCyii/advanced/backend/web/index.php?r=tproducta/create"

etc…