I try to check through class_exists - the function for some reason does not work.
The class_exists have a stupid property to try to autoload the class if the second argument is set to true (this is the default value). The function checks not the presence of a class in the current runtime, but the presence of a class in the application - is it available, if a new instance is now created using new . At the moment of loading, PHP will contact your autoloader, which will definitely try to load the file, and not include_once , after which you can save the situation, but require_once , and you do this even without checking for the existence of the file. Therefore, you have a potentially killer situation: what is new , what is class_exists .
What to do?
First of all, the autoloader should never do potentially destructive actions. There may be a lot of them , the PHP autoloader system is designed so that twelve people can come in, install on the loader, and they all worked - if one failed, the next one goes. Therefore, your autoloader should simply do nothing if it cannot find the class.
The second thing worth mentioning is Composer dependency manager. I really don’t like the fact that it combines the functions of the dependency manager and autoloader, but at the moment it is the industry standard, so the easiest thing would be to put autoloading on it.
If you still want to write your own bootloader, you need to make it check for the existence of the file and register the directory for which to count. Even better, do it according to the PSR-4 standard, according to which the Composer autoloader works. As far as I understand, you have the first warning because you specify include_path from the noodle, and PHP first looks for a class there.
In any case, after implementing the correct loader, you can class_exists use class_exists to check for the existence of a class.