I have created new controller in the project but I am getting Not Found (#404) error when I try to access it. I am using the following URL http://localhost/basic/web/index.php?r=users/index
here is the controller:
<?php
namespace app\Controllers;
use yii\web\Controller;
use app\models\Users;
class UsersController extends Controller
{
public function actionIndex()
{
$users= Users::find()->all();
return $this->render('index',['users'=>$users]);
}
}
?>
and here is the model:
<?php
namespace app\models;
use yii\db\ActiveRecord;
class Users extends ActiveRecord{
}
?>
and here is the view:
<?php
foreach($users as $user){
echo $user->username."<br/>";
}
?>
solved, the error accorded because "Controller" shouldn't start with capital letter in the namespace.