P
P
Pavel2017-02-24 17:35:40
Yii
Pavel, 2017-02-24 17:35:40

Why is Yii2 not finding classes?

I'm new to yii2 and I'm facing the same problem. BASIC application template
User.php model in the models folder:

namespace app\models;

use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;

class User extends ActiveRecord implements IdentityInterface
{

and the SignupForm.php model:
namespace app\models;


use yii\base\Model;

/**
 * Signup form
 */
class SignupForm extends Model
{
.................
   public function signup()
    {
        ....................
        $user = new User();
        ................

SiteController.php :
public function actionSignup()
    {
        $model = new SignupForm();

We go through the action, we see the form. But when submitting, in general, a wonderful error:
PHP Fatal Error - yii\base\ErrorException
Class '\common\models\User' not found

Other models from the same folder with the same namespaces work fine.
UPD7157a64f7b714e81aae2a78e28abf5fd.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-02-24
@Palych_tw

Case 1
The file is called AppointmentForm.php and the class is Appointment s Form. And they should be named the same
Case 2
Look at the stack trace of the error and look for the place where it occurs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question