DEV Community

Discussion on: php - How to fix "Class '' not found" error

Collapse
 
rehmatfalcon profile image
Kushal Niroula

I usually check the error message to see where the class is being looked at.
If, for example, I want to use an entity but the error message says App/Service/Entity was not found, I know I missed an import statement.
If that is not the case, I look at the directory structure and namespace, and then I dump-autoload at last.I usually do not have to resort to dump-autoload as I usually run it as soon I add/remove any namespaces.

Collapse
 
dechamp profile image
DeChamp

That is a great point! I will update the post to reflect what my mindset was at the time. It was for those times you have done everything you can think of. Specifically when you update the composer.json psr-4 path name.

But I'll add your information to the post about making sure you have the import, totally spaced it!