Answer the question
In order to leave comments, you need to log in
Why doesn't class_exists find the class connected by composer's autoloading?
Actually, subject. returns . But if you write the full name of the class , then everything is located.
For several hours I have been reading literature on namespaces and specifically on the autoloader, but I still don’t understand why the search function does not understand the short class name, but understands the full one. Can anyone explain?) class_exists('MyClass');
false
class_exists('App\Classes\MyClass');
Answer the question
In order to leave comments, you need to log in
Autoloading has nothing to do with it, it's just that class_exists expects to get the full path to the class along with the namespace, it does not understand the aliases of the current file.
You need to manually add the namespace to the check.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question