use Phalcon\Mvc\View; $view = new View(); // Set the template file for the view $view->setTemplate("layouts/main"); // Render the view $view->start(); $view->render("home", "index"); $content = $view->getContent(); $view->finish();
use Zend\View\Model\ViewModel; use Zend\View\Renderer\PhpRenderer; use Zend\View\Resolver\TemplateMapResolver; // Create a new view model $view = new ViewModel(); // Set the template file for the view $view->setTemplate("layouts/main"); // Create a new renderer $renderer = new PhpRenderer(); // Set the resolver for template mapping $resolver = new TemplateMapResolver([ 'layouts/main' => '/path/to/layouts/main.phtml', 'home/index' => '/path/to/home/index.phtml' ]); $renderer->setResolver($resolver); // Render the view model $output = $renderer->render($view);In this example, we create a new ViewModel instance and set the template file to "layouts/main". We then create a new PhpRenderer instance and set a TemplateMapResolver to map the template file names to their corresponding file paths. We finally render the View Model and store the output in a variable called $output. Package library: Zend Framework