public function index() { return view('welcome') ->setLayout('layouts.app'); }
public function index() { return $this->render('welcome.html.twig', [ 'title' => 'Welcome to my website' ])->setLayout('base.html.twig'); }
public function index() { $this->load->view('welcome_message', [ 'title' => 'Welcome to my website' ], false, 'layouts/main.tpl'); }In this example, the index method of a controller is loading a view called "welcome_message" with a title variable, and specifying a layout file called "layouts/main.tpl". These examples demonstrate how the setLayout function can be used in various web development frameworks to provide a consistent layout across multiple pages. Package/library used: Laravel, Symfony, and CodeIgniter are all popular PHP frameworks that provide the setLayout function.