简体   繁体   English

找不到Twig PHP模板引擎类'Twig_Loader_String'

[英]Twig PHP Template Engine Class 'Twig_Loader_String' not found

Am Trying To use the twig template engine , i included the "Autoload" file from the lib folder as bellow : 我正在尝试使用树枝模板引擎,下面是来自lib文件夹的“自动加载”文件:

require_once 'lib/Twig-1.15.0/Twig-1.15.0/lib/Twig/Autoloader.php';

$loader = new Twig_Loader_String();
$twig = new Twig_Environment($loader);

echo $twig->render('Hello {{ name }}!', array('name' => 'Fabien'));

And after i start the server i keep getting this error: 在我启动服务器后,我不断收到此错误:

Fatal error: Class 'Twig_Loader_String' not found in C:\wamp\www\school_library\index.php on line 12

I am using Wamp Server , What do you think is the problem ? 我正在使用Wamp Server,您认为是什么问题? and is the File "/lib/Twig/Autoloader.php" the right one to require ? 是文件“ /lib/Twig/Autoloader.php”正确的要求吗?

Best Regards, 最好的祝福,

Since you are not using Composer I suggest you go read this install page so that you may actually have Twig on your server. 由于您未使用Composer ,因此建议您阅读此安装页面,以便实际上可以在服务器上安装Twig I sometimes use the tarball and unpack it in a directory of my project, yet I think you should try out Composer , it seems like a very nifty tool to handle this exact situation 有时我会使用tarball并将其解压缩到我的项目的目录中,但是我认为您应该尝试Composer ,这似乎是一个非常漂亮的工具,可以处理这种情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM