PHP code example of journey / views

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

    

journey / views example snippets


// Here's one way:
$view = new Journey\View('template-file', $variables);
echo $view->render();

// Here's another:
$view = Journey\View::make('template-file', $variables);
echo $view->render();

// The quickest
echo Journey\View::make('template-file', $variables);

// file: app.php	
$view = Journey\View('master');

// ... some application logic
$variables = array(
	'title' => 'Hello World',
	'paragraph' => 'Lorum ipsum...'
);
$view->content = Journey\View::make('page', $variables);

// file: templates/master.php
<!DOCTYPE html>
<html>
	<head>
		<title>Example Website</title>
	</head>
	<body>
		<?= $content 

// file: template/page.php
<h1><?= $title 

Journey\View::defaults([
    'templates' => getcwd() . "/templates",
    'extension' => '.php',
    'variable_prefix' => null,
    'string_template' => false
]);

// Lets render the file /tmp/temporary-file.php
$view = new Journey\View('temporary-file');
$view->config(['templates' => '/tmp']);
echo $view;