1. Go to this page and download the library: Download yaf/extras 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/ */
class Bootstrap extends \Yaf\Bootstrap_Abstract {
function _initView(\Yaf\Dispatcher $dispatcher) {
$view = new \Yaf\Extras\AdaptiveView;
$path = $view->getScriptPath();
// plain text TEST
$view->on('txt', function ($file, $data) use ($path) {
return file_get_contents( $path .$file ) .' THIS IS JUST A TEST';
});
// twig
$view->on('twig', function ($file, $data) use ($path) {
$loader = new Twig_Loader_Filesystem($path);
$twig = new Twig_Environment($loader);
return $twig->loadTemplate($file)->render($data);
});
$dispatcher->disableView(); // disable auto-render
$dispatcher->setView($view);
}
}
class TestController extends \Yaf\Controller_Abstract {
public function testAction() {
$view = $this->getView();
$view->assign('content', 'Hello World');
$view->display('text.txt');
// $view->display('text.twig'); // render use twig
}
}
class FooController extends ExtendedController {
public function indexAction() {
$this->flash('yep', 'success');
$this->flashNow('nope', 'error');
foreach ($this->getFlash() as $flash) {
echo $flash['msg']; // 'nope' in current, 'yep' for next
echo $flash['type'];
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.