Skip to content

Instantly share code, notes, and snippets.

@brtriver
Created January 21, 2012 17:01
Show Gist options
  • Save brtriver/1653293 to your computer and use it in GitHub Desktop.
Save brtriver/1653293 to your computer and use it in GitHub Desktop.
Twig.git to twig.phar
<?php
$phar = new Phar('twig.phar', 0, 'twig.phar');
$phar->buildFromDirectory(__DIR__ . '/Twig.git/lib');
$phar->compressFiles(Phar::GZ);
$phar->setDefaultStub();
<?php
#require_once __DIR__ . '/Twig.git/lib/Twig/Autoloader.php';
require_once 'phar://'. __DIR__ . '/twig.phar/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem(__DIR__.'/templates');
$twig = new Twig_Environment($loader, array(
'cache' => __DIR__ .'/compilation_cache',
));
echo $twig->render('index.html', array('name' => 'brtriver'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment