php - Silex, using Twig in service -
i'm creating application in silex. want use twig render templates in service loading pimple. need mailer class.
i started writing application based on silex-skeleton, have twig environment in $app['twig']. problem is, when want pass service:
//app.php $app['somemodel'] = function ($app) { return new somemodel($app['twig']); };
when i'm writing this, twig stops working. subpages show:
twig_error_loader: template "(path).html.twig" not defined ().
i've tried trick:
//app.php $app['somemodel'] = function ($app) { return new somemodel($app); }; //somemodel.php class somemodel { private $twig; public function __construct($app) { $this->twig = $app['twig']; } }
but breaks twig. i've tried assign , clone $app['twig'] variable, happens.
//app.php $variable = $app['twig'] //app.php $variable = clone $app['twig']
how can use twig in service in silex?
$app->register(new silex\provider\twigserviceprovider(), array('twig.path' => __dir__.'/views', ));
to more information have silex documentation.
Comments
Post a Comment