Zend Framework升级带来的麻烦

zend-framework
俺的Zend Framework很久没有升级了,一直用的1.5。看到官方已经update到1.9了,就趁着2.0没发布之前先升到最新版吧!
不过一更新,本来跑的好好的程序down掉了,提示找不到文件:

Warning: require_once(Zend_Db_Adapter_Pdo_Mysql.php) [function.require-once]: failed to open stream: No such file or directory in E:\project\bbs\shenmu\plugins\101\www\index.php on line 7

Fatal error: require_once() [function.require]: Failed opening required 'Zend_Db_Adapter_Pdo_Mysql.php' (include_path='../application/models;../../library;.') in E:\project\bbs\shenmu\plugins\101\www\index.php on line 7

这个文件的确不存在,是个类的路径名,不过伟大的ZF不应该帮我们自动翻译识别出来吗?以前好好的,现在不行了。记得当初给另一个程序升级到1.7时出现过类似的错误:

Warning: require_once(Zend_Controller_Action.php) [function.require-once]: failed to open stream: No such file or directory in E:\project\bbs\shenmu\plugins\101\www\index.php on line 7

Fatal error: require_once() [function.require]: Failed opening required 'Zend_Controller_Action.php' (include_path='../application/models;../../library') in E:\project\bbs\shenmu\plugins\101\www\index.php on line 7

在bootstrap加一行Zend_Loader::loadClass(‘Zend_Controller_Action’);就OK。原来,随着Zend Framework的升级,程序效率问题越来越受到重视,很多以前会自动加载的类现在都要手动指定了才行了。1.7取消了自动加载Zend_Controller_Action,现在1.9又取消了Db_Adapter。现在想偷懒是不行了,如果你遇到上面的问题,记得在你的启动文件里加上:

Zend_Loader::loadClass('Zend_Controller_Action');
Zend_Loader::loadClass('Zend_Db_Adapter_Pdo_Mysql');
Zend_Loader::loadClass('Zend_Db_Profiler');

他人在说:

由于改进了 Zend_Loader 和 Zend_Controller,性能应该会得到提升。这个改进是 Zend Framework 提高效率的体现,需要用到什么包就加载什么包,以前需要提高效率那么只能使用 require_once 或 include_once 这样的语法,而使用registerLoader又会不管3721都加载指定的include_path的内容,那么明显降低了效率。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据