集成工作正常。但是,当我尝试将其与xgettext集成为模板字符串时,我会遇到致命的错误。有错误
致命错误:未捕获的Twig_Error_Loader:无法找到模板“C:/MAMP/htdocs/views/site/blocks/contactform.html”(查看: C:\ MAMP \ htdocs中/视图/网站)。在 C:\ MAMP \ htdocs \ components \ twig \ Loader \ Filesystem.php:232堆栈跟踪: 0 C:\ MAMP \ htdocs \ components \ twig \ Loader \ Filesystem.php(150):Twig_Loader_Filesystem-> findTemplate('C:/ MAMP / htdocs / ...')#1 C:\ MAMP \ htdocs中\部件\枝杈\ Environment.php(329): Twig_Loader_Filesystem-> getCacheKey('C:\ MAMP \ htdocs / ...')#2 C:\ MAMP \ htdocs中\部件\枝杈\ Environment.php(419): Twig_Environment-> getTemplateClass('C:\ MAMP \ htdocs / ...')#3 C:\ MAMP \ htdocs中\控制器\ mainController.php(43): Twig_Environment-> loadTemplate('C:\ MAMP \ htdocs / ...')#4 C:\ MAMP \ htdocs中\控制器\ siteController.php(22): mainController-> loadTwig()#5 C:\ MAMP \ htdocs中\部件\ router.php(83): siteController-> actionIndex()#6 C:\ MAMP \ htdocs \ index.php(12): Router-> Run()#7 {main}抛出 第232行的C:\ MAMP \ htdocs \ components \ twig \ Loader \ Filesystem.php
这是我的代码:
class mainController {
var $twig = null;
public $configs;
public $langlibrary;
const DEFAULT_LANGUAGE = 'en';
public function __construct() {
$this->configs = Config::getConfigiration();
}
public function loadTwig() {
require_once 'components/Twig/Autoloader.php';
Twig_Autoloader::register();
$tplDir = ROOT.'/views/site';
$tmpDir = 'cache';
$loader = new Twig_Loader_Filesystem($tplDir);
$this->twig = new Twig_Environment($loader, array(
'cache' => $tmpDir,
'auto_reload' => true
));
$this->twig->addExtension(new Twig_Extensions_Extension_I18n());
// THE PROBLEM BEGINS WHEN ADD CODE BELOW FOR INETGRATION
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
{
// force compilation
if ($file->isFile()) {
$this->twig->loadTemplate(str_replace($tplDir.'/', '', $file));
}
}
答案 0 :(得分:0)
错误是我的计算机中的Windows Web开发环境。顺便说一句,我尝试了所有这些Wamp,Mamp,Denwer都是这个问题。所以最好使用Linux)