E
E
Evgeny Khripunov2018-03-04 12:40:00
Yii
Evgeny Khripunov, 2018-03-04 12:40:00

Why doesn't Yii find the class when calling it in the web folder?

There is a test.php file, it is in the web/example folder (I need access to the script via the link, so I threw it there)
The contents of test.php

<?php
use app\models\User;
User::findOne(1);

I try to reach "advanced/web/example/test.php" and get an error:
Fatal error: Class 'app\models\User' not found in C:\OpenServer\domains\advanced\web\example\test.php on line 13
I'm using yii2 basic.
Everything is fine with the User model itself with namespace : namespace app\models; and it is perfectly called in other places.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gleb Starkov, 2018-03-04
@colonel

Because you need to connect autoload
Or connect the file directly via require_once for example.
autoload

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question