Tom Wininger Tom Wininger - 8 months ago 195
PHP Question

Class app\models\user not found yii2

I did user authentication on yii2 and in the local it works just find but after when I pulled it to server I'm getting this error Class 'app\models\user' not found and this is the marked area I'm getting

$identity = $class::findIdentity($id);

, does anyone knows what is the problem?


When you are storing class name in variable, use full namespace with leading slash:

$class = '\app\models\User';
$identity = $class::findIdentity($id);

Also make sure the class with this name and namespace really exists.

And the class name should start with capital letter - User, not user. It helps to avoid possible problems with letter case on different OS.