public function display($file) { $file = APP . '/views/' . $file; if(is_file($file)) { $loader = new \Twig\Loader\FilesystemLoader(APP . '/views'); $twig = new \Twig\Environment($loader, [ 'cache' => '/path/to/compilation_cache', 'debug' => DEBUG ]); $template = $twig->load('index.html'); $template->display($this->assign?$this->assign:""); } }
不需要引入, 直接就可以用, 可以去掉这行。 可能是因为composer autoload.php已引入