I created my model, call it in another model and get an error

Unable to find 'frontend\models\profile\UploadForm' in file: /home/dev/www/mcs/frontend/models/profile/UploadForm.php. Namespace missing? 

How can this be caused?

That's what's there now (start):

 <? namespace app\models; namespace frontend\models\profile; use yii\base\Model; use yii\web\UploadedFile; class UploadForm extends Model { 

    1 answer 1

    It also says what - the /home/dev/www/mcs/frontend/models/profile/UploadForm.php file found the autoloader found, but it cannot find the \ frontend \ models \ profile \ UploadForm class. Check namespace name should be

     namespace frontend\models\profile; 

    Check the case of letters in the class name - should be class UploadForm

    • did not help, added code to the question - Diefair
    • @Diefair cannot have two namespace declarations - remove the namespace app\models . If you need to use this namespace, then use app\models and always after the line namespace app\models - Goncharov Alexander
    • removed the term namespace app\models - the problem remained - Diefair
    • @Diefair file not found then. Check that on the path /home/dev/www/mcs/frontend/models/profile/UploadForm.php exactly it is located. Verify that the file is included by adding var_dump(123); die(); to the top of the file var_dump(123); die(); var_dump(123); die(); (in general, classical PHP debugging), try <? replace with <?php . - Goncharov Alexander
    • such a stupid mistake. it was necessary just instead of <? write <?php . thank you - Diefair