PHP code example of enlivenapp / vision
1. Go to this page and download the library: Download enlivenapp/vision 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/ */
enlivenapp / vision example snippets
use Enlivenapp\Vision\Engine;
$vision = new Engine();
// Optional: register custom tags (callable inside {% %})
$vision->tags()->register('base_url', fn(string $path = '') => '/myapp/' . ltrim($path, '/'));
$vision->tags()->register('current_year', fn() => date('Y'));
// Optional: register custom filters (used with | in templates)
$vision->filters()->register('slug', fn($val) => strtolower(preg_replace('/[^a-z0-9]+/i', '-', $val)));
echo $vision->render('/path/to/views/page.tpl', [
'title' => 'My Page',
'items' => ['one', 'two', 'three'],
'user' => ['name' => 'Admin', 'email' => '[email protected] '],
]);
$vision->filters()->register('reverse', fn($val) => strrev((string) $val));
$vision->filters()->register('truncate', fn($val, $len = 100) => mb_substr($val, 0, $len) . '...');
$vision->render(
'/app/modules/blog/views/post.tpl',
$data,
'/app/shared/views/' //