PHP code example of boshurik / twig-petrovich-extension
1. Go to this page and download the library: Download boshurik/twig-petrovich-extension 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/ */
boshurik / twig-petrovich-extension example snippets
use Staticall\Petrovich\Petrovich;
use Staticall\Petrovich\Petrovich\Loader;
use BoShurik\Petrovich\Twig\Extension\PetrovichExtension;
use Twig\Environment;
$petrovich = new Petrovich(Loader::load('/path/to/rules.json'));
$extension = new PetrovichExtension($petrovich);
$twig = new Environment($loader);
$twig->addExtension($extension);
use Staticall\Petrovich\Petrovich;
use Staticall\Petrovich\Petrovich\Loader;
use BoShurik\Petrovich\Twig\Extension\PetrovichExtension;
$factory = function () {
return new Petrovich(Loader::load('/path/to/rules.json'));
};
$extension = new PetrovichExtension($factory);