1. Go to this page and download the library: Download wyrihaximus/twig-view 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/ */
wyrihaximus / twig-view example snippets
namespace App\View;
use WyriHaximus\TwigView\View\TwigView;
class AppView extends TwigView
{
}
<?= $this->fetch('content')
use Cake\Event\EventListenerInterface;
use Goetas\Twital\TwitalLoader;
use WyriHaximus\TwigView\Event\ConstructEvent;
use WyriHaximus\TwigView\Event\LoaderEvent;
class LoaderListener implements EventListenerInterface
{
public function implementedEvents(): array
{
return [
LoaderEvent::EVENT => 'loader',
ConstructEvent::EVENT => 'construct',
];
}
public function loader(LoaderEvent $event): void
{
$event->result = new TwitalLoader($event->getLoader());
}
/**
* We've also listening in on this event so we can add the needed extensions to check for to the view
*/
public function construct(ConstructEvent $event): void
{
$event->getTwigView()->unshiftExtension('.twital.html');
$event->getTwigView()->unshiftExtension('.twital.xml');
$event->getTwigView()->unshiftExtension('.twital.xhtml');
}
}
use Cake\Event\EventListenerInterface;
use WyriHaximus\TwigView\Event\ConstructEvent;
class LoaderListener implements EventListenerInterface
{
public function implementedEvents(): array
{
return [
ConstructEvent::EVENT => 'construct',
];
}
public function construct(ConstructEvent $event): void
{
$event->getTwig()->addExtension(new YourTwigExtension);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.