Skip to content
Advertisement

PHP classes in namespaces not found

I tried to load a utility class to my main class with a namespace but everytime I try to run it it seems to not be working as in not finding the class. The error I got is:

JavaScript

The first array is for me to check what files is included using the get_included_file() function and I have loaded my autoload.php file which loads the rest of my utility classes. This is my code that throws the error above:

JavaScript

and my autoload.php file:

JavaScript

I tried searching online but I cannot find a solution. I tried php namespace Class not found or PHP namespace confusion, class not found

I made changes and double checked my code, I am including the utility class from autoload.php as this is the output of autoload.php

JavaScript

Is my autoloading somehow wrong? Thanks for any help in advance.

Edit: I tried to include the file only without the autoload and it is working just fine. However I would like to use the autoloader because if my classes start expanding it would be a pain to include every single file.

Advertisement

Answer

It looks like the pattern in glob is relative to the working directory, you may use a determined path.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement