集成工作得很好。但当我试图将它与xgettext for template string集成时,我得到了一个致命的错误。有一个错误
致命错误:未捕获Twig_Error_Loader:无法找到模板"C:/MAMP/htdocs/view/site/block/contactform.html"(查看:C:\MAMP\htdocs/view/site)。HTDocs\组件\twig\Loader\Filesystem.php(150):Twig_Loader_Filesystem-
这是我的代码:
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));
}
}
故障是Windows Web开发环境在我的电脑。顺便说一下,我尝试了他们所有的Wamp,Mamp,Denwer在他们所有的都是这个问题。