I cannot extend modules, help me please

Hello,

First of all sorry for my english…

I am developing a app and i cannot extend modules. It always says the same.

I done this:

I created a new file in fronten/models/Example.php

I configure the module in main.php config file

And always same error: it finds ok the file, but “Unable to find ‘app\models\Example’ in file: /var/www/html/advanced/frontend/models/Example.php. Namespace missing?”

I test with 3 different module extends and always same error. It is something that i done wrong.

Example extending RegistrationForm:


namespace app\models;


use dektrium\user\models\Profile;

use dektrium\user\models\RegistrationForm as BaseRegistrationForm;

use dektrium\user\models\User;


class RegistrationForm extends dektrium\user\models\RegistrationForm

{

    /**

     * Add a new field

     * @var string

     */

    public $izenAbizenak;


    /**

     * @inheritdoc

     */

    public function rules()

    {

        $rules = parent::rules();

        $rules[] = ['izenAbizenak', 'required'];

        $rules[] = ['izenAbizenak', 'string', 'max' => 255];

        return $rules;

    }


    /**

     * @inheritdoc

     */

    public function attributeLabels()

    {

        $labels = parent::attributeLabels();

        $labels['izenAbizenak'] = \Yii::t('user', 'Name');

        return $labels;

    }


    /**

     * @inheritdoc

     */

    public function loadAttributes(User $user)

    {

        // here is the magic happens

        $user->setAttributes([

            'email'    => $this->email,

            'username' => $this->username,

            'password' => $this->password,

        ]);

        /** @var Profile $profile */

        $profile = \Yii::createObject(Profile::className());

        $profile->setAttributes([

            'izenAbizenak' => $this->izenAbizenak,

        ]);

        $user->setProfile($profile);

    }

}

‘modules’ => [

	'user' => [


    		'class' => 'dektrium\user\Module',


		'modelMap' => [


        'RegistrationForm' => 'app\models\RegistrationForm'


    ],

If you need i post other examples.

Thank you very much

First of all you are talking about modules but I think you mean models. These are not the same.

Second - app\* namespace is used in basic application. You have got advanced application so it should be frontend\* or backend\*. Check out your folder structure and read documentation again.

yes you are right, are models sorry

i have checked using frontend/models too and same error:

Unknown Class – yii\base\UnknownClassException

Unable to find ‘app\models\RegistrationForm’ in file: /var/www/html/advanced/frontend/models/RegistrationForm.php. Namespace missing?

I think that i have somewhere "app\models" prefix where it would be frontend\models

Thank you

upsss

i think that i have located the error…

in the model file i do not open the <?php tag…i will try configuring all again and if it works i will post.

Thanks

same error…

i think that it is solved

i have done a lot of changes in every files because it was not working. Finally i have configured the frontend/config/main with common/config/main configuration. Firstly, it was also but it should be something wrong…i dont know

thank you