我们将要安装 twig/twig 模板引擎类。
首先使用composer进行下载。
"name":"MVC PHP",
"description":"PHP Framework",
"type":"Framework",
"keyworks":[
"PHP","PHP Framework"
],
"require":{
"php":">= 5.3.0",
"filp/whoops":"*",
"symfony/var-dumper":"*",
"catfan/medoo":"*",
"twig/twig":"*"
},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
2) 修改基类中的display 方法
public function display($file)
{
$filePath = APP_PATH.'application/views/'.$file;
if(is_file($filePath))
{
\Twig_Autoloader::register();
$loader = new \Twig_Loader_Filesystem(APP_PATH.'application/views');
$twig = new \Twig_Environment($loader, array(
'cache' => RUNTIME_PATH.'logs/twig',
'debug' => true
));
$template = $twig->loadTemplate($file);
$template->display($this->assign?$this->assign:'');
}
}
这样对咱们的框架也有一定的完善 效率也提高的很多