0

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.

Community
  • 1
  • 1
ZiaBoby
  • 11
  • 3
  • Can you show some code? Are you working within the correct namespace? You have to declare classes outside of the namespace before you can use them or you have to use the full path. – Wilt Dec 16 '14 at 08:48
  • I am declaring the class by prefix using the StandardAutoloader. Still my problem could be related to namespaces. Anyway I added some code. – ZiaBoby Dec 22 '14 at 16:26

0 Answers0