zend-frameworkinclude-pathzend-autoloaderzend-loader

new Zend_Loader_Autoloader not finding files


I just upgraded from ZF 1.7 to ZF 1.9, and almost everything works fine... except for Autoloader.

Old:

require_once('Zend/Loader.php');  
Zend_Loader::registerAutoload();

New:

require_once 'Zend/Loader/Autoloader.php';  
$loader = Zend_Loader_Autoloader::getInstance();  
$loader->registerNamespace('MySiteName_');
$loader->setFallbackAutoloader(true);

The files I need to auto-load are mostly not namespaced (because it's a large project from pre-namespacing). They are in the following directories:

The site seems to work fine EXCEPT that it can't find /library/Form.php
It used to be able to, but not anymore. It works if I add a require_once 'library/Form.php', but that shouldn't be necessary, and I'm worried that if I start doing that in some places, I'll need to abandon the autoloader and hard-code all includes. I thought adding "setFallbackAutoloader(true)", combined with having "library" in my include path would fix it, but it didn't.

My include path is:
.:/Users/lofye/Documents/htdocs/mysitename/vendor
:/Users/lofye/Documents/htdocs/mysitename/common
:/Users/lofye/Documents/htdocs/mysitename/common/models
:/Users/lofye/Documents/htdocs/mysitename/library
:/Users/lofye/Documents/htdocs/mysitename

Any help greatly appreciated!


Solution

  • You said it works if you do this:

    require_once 'library/Form.php';
    

    But, if your library path is included, then you should be specifying, as autoloader does, like this:

    require_once 'Form.php';
    

    Try typing require_once 'Form.php'; into your script. Does it bomb? Then, your include path doesn't have /library, and that would need to be fixed.