i am newbie to yii2.
I have created a custom component class and trying to access model class object but it showing error -
PHP Fatal Error – yii\base\ErrorException
Class ‘app\components\User’ not found
Component class : (basic\components\Functions.php)
namespace app\components;
use Yii;
use yii\base\Component;
use yii\base\Model;
use yii\base\InvalidConfigException;
class Functions extends Component
{
public function getAllUser()
{
$model = User::find()->all();
return $model;
}
}
config setting for this component :
‘components’ => [
'functions' => ['class' => 'app\components\Functions'],
]
model class :
namespace app\models;
use Yii;
class User extends \yii\db\ActiveRecord
{
public static function tableName()
{
return ‘user’;
}
public function rules()
{
}
//… other methods
}
I don’t where i am doing wrong.