Warning: include_once(Smarty\Internal\Data.php)

在整合Zend framewrok Smarty3的时候,很多人会遇到这样的一个错误
Warning: include_once(Smarty\Internal\Data.php): failed to open stream: No such file or directory in D:\web\carweb\library\Zend\Loader.php on line 146 Warning: include_once(): Failed opening ‘Smarty\Internal\Data.php’ for inclusion (include_path=’.;./library;./application/models/;.;C:\php\pear’) in D:\web\carweb\library\Zend\Loader.php on line 146 Warning: include_once(Smarty\Internal\Template.php): failed to open stream: No such file or directory in D:\web\carweb\library\Zend\Loader.php on line 146 Warning: include_once(): Failed opening ‘Smarty\Internal\Template.php’ for inclusion

(include_path=’.;./library;./application/models/;.;C:\php\pear’) in D:\web\carweb\library\Zend\Loader.php on line 146 Warning: include_once(Smarty\Internal\Resource\File.php): failed to open stream: No such file or directory in D:\web\carweb\library\Zend\Loader.php on line 146 Warning: include_once(): Failed opening ‘Smarty\Internal\Resource\File.php’ for inclusion (include_path=’.;./library;./application/models/;.;C:\php\pear’) in D:\web\carweb\library\Zend\Loader.php on line 146

遇到这样的警告是因为Smarty3重构了,使其与 Zend framewrok自动加载器与冲突。我有几个同事曾遇此项目 。他们找不到解决办法,只有关闭了 Zend 的自动加载器。我觉得那样做不太好。所以我一直在找答案。终于找到一个很好的解决方案 ,从这个警告可以看出Zend 的自动加载器正试图加载Smarty的结构,并因为 Zend 是与 ‘_’ 分割的,自动加载器找不到类。解决办法是告诉 Zend 忽略 ‘Smarty_’ 开头的所有类。在引导文件中,将添加到您的 _initAutoload() 方法的以下:
Zend_Loader_Autoloader::getInstance()->pushAutoloader(NULL, ‘Smarty_’ );
问题就这么简单 !您现在可以插入在您查看模板,无论你现在希望的方式。

发表评论

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

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>