twigphp / Twig

Twig, the flexible, fast, and secure template language for PHP
https://twig.symfony.com/
BSD 3-Clause "New" or "Revised" License
8.15k stars 1.25k forks source link

add a list of frameworks using twig to the twig website #1671

Closed ghost closed 9 years ago

ghost commented 9 years ago

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.

iekadou commented 9 years ago

I was the user. It would really help, to see the spread of twig. :+1:

anlutro commented 9 years ago

Would you include frameworks that provide optional twig integration?

ghost commented 9 years ago

well technically even symfony's twig integration is optional (before 3.0). Not sure where to draw the line exactly.

fabpot commented 9 years ago

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.

iekadou commented 9 years ago

Sylius is using it too

ghost commented 9 years ago

so projects based on symfony directly count? I guess i'm not sure where draw the line before we add every symfony app :)

fabpot commented 9 years ago

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.

kamilsk commented 9 years ago

OroCRM based on Symfony components, in particular uses the Twig

kamilsk commented 9 years ago

Yii has official extension, supported by members of core team

barryvdh commented 9 years ago

I use Twig with Laravel, but it's not 'officially' supported I guess..

ninsuo commented 9 years ago

There are lots of unofficial Twig modules for Codeigniter too.

r3wt commented 9 years ago

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');
joelpittet commented 9 years ago

Kohana has had a module for years too. https://github.com/tommcdo/kohana-twig Also: http://picocms.org/

fabpot commented 9 years ago

e375c9c