public function register() { $this->container->registerSingleton(['Test\\View\\ViewFactory', 'view'], function ($container) { $app = $container->get('app'); $applicationPath = $app->getPath(); $fileSystem = $container->get('filesystem'); // Create factory instance $factory = new ViewFactory($fileSystem, dirname($applicationPath) . '/resources/views', $app->getCharset()); // Register template renderer $factory->registerRenderer('.tpl.php', function () use($applicationPath, $fileSystem) { return new Template($fileSystem, dirname($applicationPath) . '/storage/cache/views'); }); // Return factory instance return $factory; }); }
public function index(ViewFactory $view) { return $view->render('home'); }