1. Go to this page and download the library: Download alexmasterov/equip-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/ */
namespace Acme\Domain;
use Equip\Adr\DomainInterface;
use Equip\Adr\PayloadInterface;
class WidgetDomain implements DomainInterface
{
/**
* @var PayloadInterface
*/
private $payload;
public function __construct(PayloadInterface $payload)
{
$this->payload = $payload;
}
public function __invoke(array $input)
{
return $this->payload
->withStatus(PayloadInterface::STATUS_OK)
->withSetting('template', 'widget.html.twig')
->withOutput([
'message' => 'Just do it!'
]);
}
}
// ...
use AlexMasterov\EquipTwig\Payload\PayloadRenderTrait;
class WidgetDomain implements DomainInterface
{
use PayloadRenderTrait;
public function __invoke(array $input)
{
$message = 'Just do it!';
return $this->render('widget.html.twig', compact('message'));
}
}