Zend framework not recognize classes

230 Views Asked by At

I am relatively new to Zend as I am working with Apigility.
When I try to include classes from external files, which are part of another MVC project, files are read, but creating instances returns an error.

If I use an include/require function class_exists return true, but still I can't create objects, while using one of the autoloading procedures from Zend_Loader gives the error "class *** not found" (class_exists return false in this case) and prints on screen the entire content of the file.

It's not due to my MVC, because I got the same problem including a class created on the fly. And it isn't a match problem.

Any ideas?


EDIT - As I am trying to load class User from function getServiceConfig() in Module.php of an Apigility application named 'Example'

        // Zend\Loader\StandardAutoloader namespace is stated at the beginning and it is working
        $loader = new StandardAutoloader();                 
        $loader->registerPrefix('local', '/home/mylocal/class/local'); 
        $loader->autoload('local_User'); 
        $loader->check = class_exists('User'); // states true and is listed in get_declared_classes()
        return new User(); // returns the error: Class 'Example\User' not found in /home/mylocal/apigility/module/Example/src/Example/Module.php on line *

The same code works correctly if used in the index.php file of Apigility public folder where there is no interference from Example namespace.

0

There are 0 best solutions below