Closed ghost closed 9 years ago
I was the user. It would really help, to see the spread of twig. :+1:
Would you include frameworks that provide optional twig integration?
well technically even symfony's twig integration is optional (before 3.0). Not sure where to draw the line exactly.
Let's list all frameworks/CMSes that supports Twig. Here is a first line (top of my head):
We might also want to link to their respective websites.
Sylius is using it too
so projects based on symfony directly count? I guess i'm not sure where draw the line before we add every symfony app :)
I think we need to come up with a list of "significant" projects. Problem is in the definition of significant :) ... and then, everyone will want to add his own pet project to the list.
Yii has official extension, supported by members of core team
I use Twig with Laravel, but it's not 'officially' supported I guess..
There are lots of unofficial Twig modules for Codeigniter too.
Slim 2.6.2 + Twig in 2 easy steps
namespace FooBar;
class Application
{
public static $self = null;
public $slim;
public $twig_config;
function __construct($slim_config,$twig_config)
{
if(self::$instance === null)
{
$this->slim = (empty($slim_config) ? new \Slim\Slim() : new \Slim\Slim( $slim_args ) );
$this->twig_config = $twig_config;
self::$instance = &$this;
}else{
return self::$instance;
}
}
public static function getInstance()
{
return self::$instance;
}
public function __call($name, $args = false)
{
if(method_exists($this->slim,$name)){
if($args)
return call_user_func_array( [$this->slim,$name] , $args);
else
return call_user_func( [$callable,$name] );
}
}
}
//your view controllers should extend this
class ViewController implements ViewInterface
{
public $twig;
function __construct()
{
$this->twig = new \Twig_Environment( new \Twig_Loader_Filesystem( (\FooBar\Application::getInstance())->twig_config['template_path'] ) );
}
public function render($template,$args)
{
echo $this->twig->loadTemplate($template)->render($args);
}
}
interface ViewInterface
{
public function render($template,$args);
}
use like:
$app = new \FooBar\Application($slim_config,$twig_config);
$app->map('/controller/:method',function($method){
(new \FooBar\ViewController())->{$method}();
})->via('GET','POST');
Kohana has had a module for years too. https://github.com/tommcdo/kohana-twig Also: http://picocms.org/
e375c9c
A user in #symfony asked which frameworks other than symfony used Twig. The only thing i could think of off the the top of my head was Drupal 8. It'd be nice to have a page to point people to.