phpcomposer-phpautoload

How handle Uncaught Error : Class not found PHP / Composer?


I'm beginning a project with oop as beginner and I'm trying to use some classes that I think are recognized by vscode and composer because when I click on their namespaces it lead me to right class but when I run the code in the browser I have fatal error telling me that my class is not found.

I try many things :

I don't really know where I messed up :

Project Folder Structure

Its the index.php file (in the public folder) : enter image description here

The database.php file :

enter image description here

The article.php file : enter image description here

And finally my composer.json :

enter image description here

I don't know if its useful to say it but when I try to make a require of my model file in the index.php file its working but as I removed the require its not longer working


Solution

  • I found the solution it was related to the path that I set on composer.json my classes with the namespace "Articles" wasn't able to load correctly even if vscode can read it only because I haven't wrote the relative path like I should the "src" folder was on root but I've gone up too far on my directory that why it wasn't working so I just removed the dots and everything works fine.