Twig and Namespaces

2

Hello, I'm having a hard time implementing Twig in my project MVC , I'm using namespaces, autoloader all that PSR-0 thing. I'd like your judah to implement because I'm almost freaking out. rs

public function render($file, $data = null){        
    require_once LIB . '/Twig/Autoloader.php';
    \Twig_Autoloader::register();               

    $loader = new \Lib\Twig_Loader_Filesystem('/path/to/templates');
    $twig = new Twig_Environment($loader, array(
        'cache' => '/path/to/compilation_cache',
    ));
}

This is my method that will render the template, so far I have the following error:

Exception: Controller Twig_Autoloader not found. in C:\UwAmp\www\system\engine\autoload.php

    
asked by anonymous 23.03.2014 / 05:56

1 answer

3

Easier to use composer to do autoload, just roll

composer require "twig/twig:1.*"

and then include the autoload generated by the composer:

require_once '/path/to/vendor/autoload.php';

Twig has complete documentation that explains how to installation by composer

    
09.05.2014 / 22:19