YAF 加入smarty3之后文件加载的解决

时间:2022-12-04 16:01:22

在yaf引入smartys3作为视图的出现了如下错误:

 

Warning:  Yaf_Loader::autoload() [yaf-loader.autoload]: Failed opening script /home/www/yafwww/application/library/Smarty/Internal/TemplateCompilerBase.php: No such file or directory in /home/www/yafwww/application/library/Smarty/sysplugins/smarty_internal_smartytemplatecompiler.php on line 23
Warning: Yaf_Loader::autoload() [yaf-loader.autoload]: Failed opening script /home/www/yafwww/application/library/Smarty/Internal/Templatelexer.php: No such file or directory in /home/www/yafwww/application/library/Smarty/sysplugins/smarty_internal_smartytemplatecompiler.php on line 95
Warning: Yaf_Loader::autoload() [yaf-loader.autoload]: Failed opening script /home/www/yafwww/application/library/Smarty/Internal/Templateparser.php: No such file or directory in /home/www/yafwww/application/library/Smarty/sysplugins/smarty_internal_smartytemplatecompiler.php on line 96
Warning: Yaf_Loader::autoload() [yaf-loader.autoload]: Failed opening script /home/www/yafwww/application/library/Smarty/Internal/CompileBase.php: No such file or directory in /home/www/yafwww/application/library/Smarty/sysplugins/smarty_internal_compile_private_print_expression.php on line 18
Warning: Yaf_Loader::autoload() [yaf-loader.autoload]: Failed opening script /home/www/yafwww/application/library/Smarty/Internal/Write/File.php: No such file or directory in /home/www/yafwww/application/library/Smarty/sysplugins/smarty_internal_template.php on line 201
解决方法有两种:
1:利用require_once 将需要的文件全部加载进来。
2:利用__autoload($classname)来自动加载。
//这里是错误 不能这样加载的 如果要这样的需要把,
yaf.use_spl_autoload 把他给 开启的情况下, Yaf在加载不成功的情况下, 会继续让PHP的自动加载函数加载, 从性能考虑, 除非特殊情况, 否则保持这个选项关闭 。

 

还可以利用 Yaf_Loader::import($filename);性能会比require_once高些