Posts

Showing posts with the label vendor

Adding template engine Twig on CodeIgniter

Image
1. Download Twig vendor from http://twig.sensiolabs.org/ 2. Extract the files and copy the contents of the Twig-1.x.x\lib to /application/libraries/ Your library should have the Twig folder inside /libraries/Twig 3. Create a Twig.php inside the libraries folder then add the following code: class Twig { private $CI; private $_twig; private $_template_dir; private $_cache_dir; public function __construct($debug = false) { $this->CI =& get_instance(); self::requireTwigAutoloader(); Twig_Autoloader::register(); $this->CI->config->load('twig'); $this->_template_dir = $this->CI->config->item('template_dir'); $this->_cache_dir = $this->CI->config->item('cache_dir'); $loader = new Twig_Loader_Filesystem($this->_template_dir); $this->_twig = new Twig_Environment($loader, array( 'cache' => $this-...