PHP code example of devpontes / view

1. Go to this page and download the library: Download devpontes/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/ */

    

devpontes / view example snippets


$viewPath = 'views';

$v = new \DevPontes\View\View($viewPath, 'php');

/** set view data */
$user  = new \stdClass();
$user->name = "John Doe";
$user->age = 25;

$data['user'] = $user;

$v = new \DevPontes\View\View($viewPath, 'php');

$v->setHead('

 $this->insert('components/article') 

/** assets array */
$css = ['style'];
$js = ['script'];

/** soucer path */
$source = 'assets';

/** define cache */
$cache = false;

$a = new \DevPontes\View\Assets('assets', false);

$v->addAssets($a);
$v->assets->makeScript($js);
$v->assets->makeStyle($css);

$v->setStylePath('style');
$v->setScriptPath('script');
html
<head>
  <title>View</title>
  <!-- add CSS -->
  <?= $this->assets->getStyles() 
html
<body>
  ...
  <!-- add JS -->
  <?= $this->assets->getScripts()