Created
March 13, 2019 17:37
-
-
Save danteay/ac07236fe6a3d6d2842463dc08dff84d to your computer and use it in GitHub Desktop.
Twig dependency for Slim 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Global settings for project configuration | |
* | |
* PHP Version 7.1 | |
* | |
* @category Dependency | |
* @package CorePHP_Slim_Scafold | |
* @author Eduardo Aguilar <[email protected]> | |
* @copyright 2018 Eduardo Aguilar | |
* @license https://github.com/danteay/corephp-slim-scafold/LICENSE Apache-2 | |
* @link https://github.com/danteay/corephp-slim-scafold | |
*/ | |
return function ($c) { | |
$view = new \Slim\Views\Twig( | |
$c['settings']['renderer']['template_path'], | |
$c['settings']['twig'] | |
); | |
// Instantiate and add Slim specific extension | |
$basePath = rtrim( | |
str_ireplace('index.php', '', $c->get('request')->getUri()->getBasePath()), | |
'/' | |
); | |
$view->addExtension(new Slim\Views\TwigExtension($c->get('router'), $basePath)); | |
return $view; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment