1. Go to this page and download the library: Download dhii/php-template 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/ */
dhii / php-template example snippets
use Dhii\Output\PhpEvaluator\FilePhpEvaluatorFactory;
use Dhii\Output\Template\PhpTemplate\FilePathTemplateFactory;
use Dhii\Output\Template\PathTemplateFactoryInterface;
function (): PathTemplateFactoryInterface {
return new FilePathTemplateFactory(
new FilePhpEvaluatorFactory(),
[ // This will be available by default in all contexts of all templates made by this factory
'time' => time(), // Let's assume it's 1586364371
],
[ // This will be available by default in all templates made by this factory
'uc' => function (string $string) {
return strtoupper($string);
},
]
);
};
use Dhii\Output\Template\PathTemplateFactoryInterface;
use Dhii\Output\Template\PhpTemplate\FilePathTemplateFactory;
/* @var $fileTemplateFactory FilePathTemplateFactory */
(function (PathTemplateFactoryInterface $factory) {
$template = $factory->fromPath('template.php');
echo $template->render([
'username' => 'jcdenton',
'password' => 'bionicman',
'status' => 'defected',
]);
})($fileTemplateFactory); // This is the factory created by above configuration
/* @var $c callable */
/* @var $f callable */
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.