PHP code example of rkr / view

1. Go to this page and download the library: Download rkr/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/ */

    

rkr / view example snippets


$factory = new FileViewFactory(__DIR__.'/path/to/my/template/folder');
$renderer = $factory->create('module');
$renderer->add('myVar', 1234);
$content = $renderer->render('action');
echo $content;

class MyCtrl {
	/** @var ViewFactory */
	private $viewFactory;

	/**
	 * @param ViewFactory $viewFactory
	 */
	public function __construct(ViewFactory $viewFactory) {
		$this->viewFactory = $viewFactory;
	}

	/**
	 * @return string
	 */
	public function someAction() {
		$content = $this->viewFactory->create('module')
		->add('myVar', 1234)
		->render('action');
		return $content;
	}
}

 /* @var \View\Workers\Worker $this */ 

 /* @var \View\Workers\Worker $this */ 

 /* @var \View\Workers\Worker $this */ 

 /* @var \View\Workers\Worker $this */