1. Go to this page and download the library: Download mkgor/puff 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/ */
mkgor / puff example snippets
ne = new \Puff\Engine([
'modules' => [
new \Puff\Modules\Core\CoreModule()
]
]);
echo $engine->render(__DIR__ . '/template.puff.html', [
'variable' => 'Puff'
]);
$engine = new \Puff\Engine([
'modules' => [
new \Puff\Modules\Core\CoreModule()
new \Puff\Modules\NewModule\MyModule()
]
]);
...
/**
* Returns an array of elements and filters which will be initialized
*
* @return array
*/
public function setUp(): array
{
return [
'elements' => [
'new_element' => new NewElement(),
'another_new_element' => new AnotherNewElement()
],
...
];
}
...
use Puff\Compilation\Element\AbstractElement;
/**
* Class NewElement
*/
class NewElement extends AbstractElement
{
/**
* @param array $attributes
* @return mixed
*/
public function process(array $attributes)
{
return " echo 'Some result of processing';
use Puff\Compilation\Element\AbstractElement;
/**
* Class NewElement
*/
class NewElement extends AbstractElement
{
/**
* @param array $attributes
* @return mixed
*/
public function process(array $attributes)
{
return " echo $attributes['result'];
/**
* Returns an array of elements and filters which will be initialized
*
* @return array
*/
public function setUp(): array
{
return [
...
'filters' => [
'new_filter' => NewFilter::class
]
];
}
...