PHP code example of lroot / simple-view

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

    

lroot / simple-view example snippets


// Setup Configuration
SimpleView::setConfigProperties(array(
    SimpleView::CONFIG_VIEW_DIR   => YOUR_APP_PATH.'/app/views/',
    SimpleView::CONFIG_LAYOUT_DIR => YOUR_APP_PATH.'/app/views/_layouts/',
    SimpleView::CONFIG_PARTS_DIR  => YOUR_APP_PATH.'/app/views/_partials/'
));

// Output your view script. Parameters: view script, data & layout
echo SimpleView::render('your-view-script', array('name'=>'Amanda'), 'your-layout');

SimpleView::placeholderSetContent('placeholder_name','placeholder content');

 SimpleView::placeholderCaptureStart('placeholder_name'); 

echo SimpleView::placeholderGetContent('placeholder_name');

// Execute a partial script and echo its content
echo SimpleView::partial('title.php',array('name'=>'Amanda'));
HTML+PHP
 SimpleView::placeholderCaptureStart(SimpleView::PLACEHOLDER_HEAD_CONTENT); 
HTML+PHP
 SimpleView::placeholderCaptureStart(SimpleView::PLACEHOLDER_INLINE_SCRIPTS);