PHP code example of maslosoft / miniview

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

    

maslosoft / miniview example snippets


namespace Company\SomeNamespace;

use Maslosoft\MiniView\MiniView;

class MyWidget
{

	/**
	 * View renderer
	 * @var MiniView
	 */
	public $view = null;
	
	/**
	 * @var string
	 */
	public $version = '';

	public function __construct()
	{
		$this->view = new MiniView($this);
		$this->version = $this->view->getVersion();
	}

	public function show()
	{
		return $this->view->render('myView', ['user' => 'Joe'], true);
	}

	public function greet($name)
	{
		return "Nice to meet you $name!" . PHP_EOL;
	}
}

Hello <?= $user 

use Company\SomeNamespace\MyWidget;

$widget = new MyWidget;

echo $widget->show();