when I use \yii\helpers\Ur in my login module, yii2 throw a exception with message "Class 'yii\helpers\Url' not found". But if I use "use yii\helpers\Ur" before my class, the exception never throw again.
My english is poor, I don't known if you can understand what I mean.
many thanks.
Can you provide exact code you're using? Also a screenshot of error would be great.
<?php
namespace backend\modules\login\controllers;
use Yii;
use yii\web\Controller;
use backend\models\User;
use backend\components\Js;
use backend\components\Acl;
#use yii\helpers\Url;
class IndexController extends Controller
{
public $enableCsrfValidation = false;
public function init()
{
parent::init();
}
public function actionIndex()
{
return $this->renderPartial('index');
}
public function actionDologin()
{
$username = Yii::$app->request->post('username', '');
$password = Yii::$app->request->post('password', '');
$userInfo = User::findOneUserByName($username);
if(User::checkPassWord($password, $userInfo->password))
{
$sessionObj = new \backend\components\SessionCookieStore();
$sessionObj->setUserLoginSession($userInfo);
$sessionObj->setUserPermissionSession($userInfo);
return Js::locate(\yii\helpers\Url::toRoute('/index/index'), 'parent');
}
return Js::error('error');
}
public function actionLogout()
{
Yii::$app->session->removeAll();
return $this->redirect(['/login/index/index']);
}
}
It's unlikely a Yii issue because this helper is being used in several places in the application templates and other classes without any problem. Please try to simplify your code to find out the cause of the issue. I don't think we can help here.
I am with the same issue any solution?
Has the same issue, but only time to time.