我无法让 Smarty 模板引擎在我的本地测试服务器上正常工作。我的设置是这样的:
<?php
// put full path to Smarty.class.php
require('smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->testInstall();
$smarty->setTemplateDir('smarty/templates');
$smarty->setCompileDir('smarty/templates_c');
$smarty->setCacheDir('smarty/cache');
$smarty->setConfigDir('smarty/configs');
$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');
?>
但是,我不断收到此错误:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in /var/www/WEBSITE/smarty/sysplugins/smarty_internal_templatebase.php:127 Stack trace: #0 /var/www/WEBSITE/smarty/sysplugins/smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('index.tpl', NULL, NULL, NULL, true) #1 /var/www/WEBSITE/test.php(13): Smarty_Internal_TemplateBase->display('index.tpl') #2 {main} thrown in /var/www/WEBSITE/smarty/sysplugins/smarty_internal_templatebase.php on line 127
我使用了 testInstall 函数,它被返回:
Smarty Installation test...
Testing template directory...
/var/www/SteamKing/templates is OK.
Testing compile directory...
FAILED: /var/www/SteamKing/templates_c is not writable.
Testing plugins directory...
/var/www/SteamKing/smarty/plugins is OK.
Testing cache directory...
FAILED: /var/www/SteamKing/cache is not writable.
Testing configs directory...
FAILED: ./configs/ does not exist.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
我经历了整个过程,确保文件夹实际上是可写的,但我仍然得到错误。有任何想法吗?