Answer the question
In order to leave comments, you need to log in
What should a class look like for the Yii2 autoloader to load it?
I am learning Yii2 as the first PHP framework from the book Web Application Development With YII2 and PHP.
In it, the approach is slightly different from the standard one, and for the first few models two classes are used - for example, Customer, which stores data, and CustomerRecord, which inherits ActiveRecord, the controller is written accordingly.
The problem arose after the creation of the above model in essence CRUD. In the controller, the CustomerRecord object is normally created, but when the Customer class is initialized, the exception "Unable to find 'app\models\customer\Customer' in file: D:\xampp\projects\yii2.local\www/models/customer/Customer.php" is thrown . Namespace missing?".
At the same time, the namespaces in the class are arranged correctly, do not differ from each other and from how they are arranged in the code example that the author of the book offers.
Similar classes Phone and PhoneRecord behave the same way.
Answer the question
In order to leave comments, you need to log in
Well, it looks like the Customer.php file either declares namespace creation incorrectly, or the file is in the wrong place where it should be.
Try to name the Customer class itself in a different way, I think this might cause problems
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question