我有一个大问题。我使用Twig模板,但现在我在屏幕上看到了错误页面。
Fatal error: Uncaught exception 'LogicException' with message 'You must set a loader first.' in C:\wampd\www\projects\weborangoo\vendor\twig\twig\lib\Twig\Environment.php on line 622
(!)
LogicException: You must set a loader first. in C:\wampd\www\projects\weborangoo\vendor\twig\twig\lib\Twig\Environment.php on line 622
但我的装载机看起来像这样:
<?php
namespace Ilib\Template;
use Twig_Loader_Filesystem;
use Twig_Environment;
class Template extends Twig_Environment {
public $template;
public $loader;
public $cache_dir = 'templates/cache';
public function __construct() {
parent::__construct();
\Twig_Autoloader::register();
$this->loader = new Twig_Loader_Filesystem( 'templates' );
$this->twig = new Twig_Environment( $this->loader , array ( 'cache' => $this->cache_dir ));
}
public function display($name, array $context = array()) {
parent::display($name, $context); }
}
问题出在哪里?我需要在模板中显示数据,但数据是一个数组,所以我不知道错误在哪里。