PHP code example of codemonster-ru / razor

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

    

codemonster-ru / razor example snippets


use Codemonster\View\View;
use Codemonster\View\Locator\DefaultLocator;
use Codemonster\Razor\RazorEngine;

$locator = new DefaultLocator([__DIR__ . '/resources/views']); // you can specify an array of paths
$engine = new RazorEngine($locator, 'razor.php', __DIR__ . '/storage/cache/views');

$view = new View(['razor' => $engine], 'razor');

echo $view->render('emails.welcome', ['user' => 'Vasya']);