Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install TWIG template engine stand alone, without composer

I want to install and use Twig as in a module and I copied the contents of the /lib/twig/ contents to to a folder called /twig in my modules folder. I've in put require_once('twig/Autoloader.php'); at the top of my module and I use Twig_Autoloader::register() to try and get it work but as soon as I use

$this->loader = new Twig_Loader_Filesystem($path);
$this->twig = new Twig_Environment($this->loader, array(
    //options
));

And I get this error: Fatal error: Class 'Twig_Loader_Filesystem' not found in

How do I resolve this?

like image 955
Hawiak Avatar asked Nov 21 '13 03:11

Hawiak


People also ask

Is twig a template engine?

Twig is a modern template engine for PHPSecure: Twig has a sandbox mode to evaluate untrusted template code. This allows Twig to be used as a template language for applications where users may modify the template design.

Where is twig is to be installed?

The Twig files are downloaded into the vendor/Twig folder. If you add other dependencies, they will also be installed in the vendor folder.

Is twig a frontend?

Twig is a modern, robust, OOP-based PHP templating engine. It's a tool used to output variables inside HTML, and it makes your site's frontend simpler, cleaner, dryer, and more logical. Its file and folder organization is essential, and how to use its tags, function, and filters.


1 Answers

Rename your twig folder to Twig, and then change your include:

require_once('Twig/Autoloader.php');

It should work now.

like image 198
Arthur Avatar answered Nov 11 '22 18:11

Arthur