PHP code example of basster / twig-base64-extension
1. Go to this page and download the library: Download basster/twig-base64-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/ */
basster / twig-base64-extension example snippets
$converter = new \Basster\TwigBase64\Converter\ImageToBase64Converter(new \Symfony\Component\Serializer\Normalizer\DataUriNormalizer());
$extension = new \Basster\TwigBase64\Twig\Base64ImageExtension($converter);
$twig = new \Twig\Environment($loader);
$twig->addExtension($extension);
yaml
services:
_defaults:
public: false
autowire: true
autoconfigure: true
Basster\TwigBase64\Converter\ImageToBase64Converter: ~
Basster\TwigBase64\Twig\Base64ImageExtension: ~
Basster\TwigBase64\Converter\FileConverterInterface: '@Basster\TwigBase64\Converter\ImageToBase64Converter'