1. Go to this page and download the library: Download felicity-php/felicity-twig 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/ */
felicity-php / felicity-twig example snippets
use felicity\twig\Twig;
$twig = Twig::get();
$twig->getLoader()->addPath('path/to/custom/template/dir', 'mynamespace');
$html = $twig->render('@mynamespace/path/to/template.twig');
use felicity\config\Config;
// Enabled Twig debug
Config::set('felicity.twig.debug', true);
// Set a string or array of template paths for the loader
Config::set('felicity.twig.templatePaths', []);
// Set the charset. UTF-8 is the default
Config::set('felicity.twig.charset', 'UTF-8');
// Set a different base template class than the default
Config::set('felicity.twig.base_template_class', 'Custom_Twig_Template');
// Set a cache location for Twig to use.
// It is HIGHLY recommended that you set this
Config::set('felicity.twig.cache', 'path/to/cache/dir');
// Whether to reload the template if the original source changed.
// You should probably leave this as default
Config::set('felicity.twig.auto_reload', true);
// Enable strict variables
Config::set('felicity.twig.strict_variables', true);
// Change autoescape preferences
Config::get('felicity.twig.autoescape', 'html');
// Disable optimizations (probably don't do this)
Config::get('felicity.twig.optimizations', 0)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.