PHP code example of davewid / owl

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

    

davewid / owl example snippets

 php


// Please don't do this as the Mustache engine is default, this is just an example
$engine = new \Owl\Engine\Mustache;
\Owl\View::setEngine($engine);
 php


$path = __DIR__.DIRECTORY_SEPARATOR."views";
$finder = new \Owl\Finder\FileSystem($path);
\Owl\View::setFinder($finder);
 php 


class Homepage extends \Owl\View
{
	public $name = "Dave";
	public $title = "Welcome";
}
 php


// Assuming file finder is already set from above.
$content = new Homepage;

echo $content->render(); // Output: Hello Dave
// echo $content; <-- this works too
 php


class Layout_Browser extends \Owl\Layout
{
	public $title = "My Page";
}
 php


$layout = new Layout_Browser;
$layout->setContent($content);
echo $layout->render();
 php


class Homepage extends \Owl\View
{
	public $name = "Dave";
	public $title = "Welcome";

	public function addedToLayout(\Owl\Layout $layout)
	{
		$layout->title .= "» {$this->title}";
	}
 php


// Anything that implements \Owl\Session will work.
$session = new \Owl\Session\Kohana;
\Owl\Message::setSession($session);
 php


\Owl\Message::get();
 php


\Owl\Message::set($type, $message);
 php


\Owl\Message::error($message);
\Owl\Message::success($message);
\Owl\Message::notice($message);
\Owl\Message::warn($message);