04/07
2016
Wallogit.com
2017 © Pedro Peláez
Silex Smarty Trait
Smarty Trait for Silex, (*1)
The best way to install Smarty Trait is to use a Composer:, (*2)
php composer.phar require junker/smarty-trait
class Application extends \Silex\Application { use \Junker\Silex\Application\SmartyTrait; }
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; $app->get('/', function() use ($app) { return $app->render('index.tpl', ['name' => 'Junker']); $response = new Response(); $response->setTtl(10); return $app->render('index.tpl', ['name' => 'Junker'], $response); return $app->render('index.tpl', ['name' => 'Junker'], new StreamedResponse()); });
http://silex.sensiolabs.org/doc/master/usage.html#traits, (*3)