【发布时间】:2017-08-06 10:32:43
【问题描述】:
这是位于我网站根目录中的config.php 文件:
<?php
define('SITE_ROOT', dirname(__FILE__));
define('CORE_DIR', SITE_ROOT . '/core');
define('VIEWS_DIR', SITE_ROOT . '/views');
define('ASSETS_DIR', SITE_ROOT . '/assets');
require SITE_ROOT . '/vendor/autoload.php';
require CORE_DIR . '/DBConnector.php';
$loader = new Twig_Loader_Filesystem(VIEWS_DIR);
$twig = new Twig_Environment($loader);
function loadHead($title) {
global $twig;
echo $twig->render(VIEWS_DIR . '/head.html', array('naslov' => $title));
}
SITE_ROOT 是/Applications/XAMPP/xamppfiles/htdocs/site_name,其中config.php 也位于,head.html 位于views 文件夹中。
但是,每当我尝试访问站点根目录中的任何页面时,我仍然会收到错误消息。
Fatal error: Uncaught Twig_Error_Loader: Unable to find template "/Applications/XAMPP/xamppfiles/htdocs/site_name/views/head.html" (looked into: /Applications/XAMPP/xamppfiles/htdocs/site_name/views).
到目前为止,我尝试重新启动 Apache 服务器,检查目录两次以确保文件实际上在那里(它是,我可以通过浏览器直接访问它),检查文件夹权限并清除缓存但没有任何效果。
【问题讨论】: