简体   繁体   中英

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 :

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 ? and is the File "/lib/Twig/Autoloader.php" the right one to require ?

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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