1. Go to this page and download the library: Download phpbook/view library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
My View Example Two using another view inside
echo (new \PHPBook\View\View)
->setPathRoot('anotherAlias')
->setView('subpath/to/file/view')
->render();
/*********************************************
*
* Rendering Views
*
* *******************************************/
$jhon = new StdClass;
$jhon->name = 'Jhon';
$jhon->age = 15;
$title = $jhon->name;
$ana = new StdClass;
$ana->name = 'Ana';
$ana->age = 15;
$paul = new StdClass;
$paul->name = 'Paul';
$paul->age = 16;
$friends = [$ana, $paul];
//data must be an array os values
$content = (new \PHPBook\View\View)
->setView('subpath/to/file/view/one')
->setData([
'title' => $title,
'jhon' => $jhon,
'friends' => $friends
])
->render();
echo $content;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.