use PhpViewRender\PhpViewRender; $view = new PhpViewRender(); $view->setViewPath('/path/to/views'); $view->setTemplate('home.php'); $view->setData([ 'title' => 'Homepage', 'content' => 'Welcome to my website!' ]); echo $view->render();
use PhpViewRender\TwigViewRender; $view = new TwigViewRender(); $view->setViewPath('/path/to/views'); $view->setTemplate('home.twig'); $view->setData([ 'title' => 'Homepage', 'content' => 'Welcome to my website!' ]); echo $view->render();This example shows how to render a Twig template using PHP View Render's `TwigViewRender` class. It follows a similar pattern to the previous example, but uses the `TwigViewRender` class instead of `PhpViewRender`. It also sets the template file with a `.twig` extension and uses Twig syntax in the template. Overall, PHP View Render is a powerful package library that provides an efficient way to render views and templates in PHP applications. It supports various template languages and provides a flexible and easy-to-use API.