PHP code example of greg-md / php-view

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

    

greg-md / php-view example snippets


$viewsDirectory = __DIR__ . '/views';

$viewer = new \Greg\View\Viewer($viewsDirectory);

// Turn it to a callable, to load only when using blade templates.
$viewer->addExtension('.blade.php', function () {
    $compiledViewsDirectory = __DIR__ . '/compiled';

    return new \Greg\View\ViewBladeCompiler($compiledViewsDirectory);
});

$content = $viewer->render('welcome', [
    'name' => 'Greg',
]);

echo $content;