In the file /controllers/AddController.php connected through the use class from another file.

 <? use Models\categoryBild; $category = new categoryBild; class AddController{ public function actionView(){ $category = new categoryBild; } } 

Sam connected file models/category.php .

 <? namespace Models; class categoryBild{ public function category(){ $category = array('men','woman', 'el_acs'); return $category; } } 

But the class does not connect, Uncaught Error: Class 'Models\categoryBild' not found in

What's wrong?

  • Well, at least the class should be called the same as the file, and with a capital letter - Anton Kucenko
  • one
    Show the code require / include - user3127286
  • @AntonKucenko why would you? - rjhdby
  • one
    You have already asked - where is the autoloader? If you use any known framework, indicate its name , by tag or in the text of the question. In frameworks, everything works, because it has its own autoloader , but you do not know about it. - u_mulder
  • one

1 answer 1

PSR standards should be taken into account and begin with a capital letter when using your categoryBild class call using composer autoload

Or use your own autoload implementation. Automatic class loading