开发者

Troubleshooting Zend Framework Autoloader

开发者 https://www.devze.com 2023-04-12 17:16 出处:网络
Can anyone recommend a way to troubleshoot why a particular class isn\'t being loaded by the autoloader? I\'m using namespace autoloading as such:

Can anyone recommend a way to troubleshoot why a particular class isn't being loaded by the autoloader? I'm using namespace autoloading as such:

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

if (APPLICATION_ENV == 'development') {
    $loader->suppressNotFoundWarnings(false);
}

Some classes in the Xyz namespace are being loaded while others aren't. In the place where the e开发者_Go百科rror is being thrown about the class not being found, I can add a require_once to the class file and it works fine.

I've seen this question: zend_loader_autoloader does not seem to load abstract class where the poster debugged Zend_Loader, but when I do so, the only classes I see it autoloading are Zend_ and ZendX_ classes. Where do other registered namespaces get loaded, and is there a way to dump all of the classes that are loaded at a given point in my code?


You need to specify to application.ini

1) autoloaderNamespaces[] = "Xyz"

2) Be shore that you have the Xyz folder in your library .

3) Create a file like test.php in Xyz

4) In test.php you need to have class Xyz_test extends ....

5) In index controler try to $var = new Xzy_test();


I ended up figuring out what my problem was. I was finally able to track it down by stepping through the autoloader line by line. What happened was when I was converting my classes from using "userland" namespaces (Xyz_My_ClassName) to use a PHP namespace definition at the top of each class, I missed changing my import declarations, so the autoloader was looking for the old class name. Thanks to everyone who helped me track this down.

0

精彩评论

暂无评论...
验证码 换一张
取 消