I don't know what going on, I was setting my mongodb
before. then I refresh my page and suddenly there was an error notification asking for namespace missing
Unable to find 'application\modules\home\models\User' in file: F:\aplikasi\laragon\www\yiiad\application/modules/home/models/User.php. Namespace missing?
I have already checked the codes I made before, and still don't know where my mistakes
This is my models user structure \application\modules\home\models\user
this models\user code
<?php
namespace home\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\db\Query;
use yii\web\IdentityInterface;
class User extends ActiveRecord implements IdentityInterface
{}
?>
My Alias
<?php
Yii::setAlias('@modules', dirname(dirname(__DIR__)) . '/application/modules');
My Path setting
'basePath' => '@modules/home',
'modules' => [
'admin' => [
'class' => 'admin\Module'
],
'home' => [
'class' => 'home\Module'
],
],
My modules
<?php
namespace home;
class Module extends \yii\base\Module{
public function init()
{
parent::init();
if (\Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'home\controllers';
}
}
}
Namespace home
is incorrect. You should use modules
alias in the namespace of the module
namespace modules\home;
class Module extends \yii\base\Module
{
}
and in config
'modules' => [
'home' => [
'class' => 'modules\home\Module'
],
],
Or you must set alias for home
directory
'aliases' => [
'@home' => 'path to home directory'
],
'modules' => [
'home' => [
'class' => 'home\Module'
],
],