PHP Classes

File: demo/index.php

Recommend this page to a friend!
  Classes of Boss Ibrahim Mussa   Wepesi PHP View Class   demo/index.php   Download  
File: demo/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Wepesi PHP View Class
Renders view output from template script files
Author: By
Last change:
Date: 1 year ago
Size: 613 bytes
 

Contents

Class file image Download
<?php
include "vendor/autoload.php";
use
Wepesi\Routing\Router;
use
Wepesi\View;


$router = new Router();

$router->get('/', function () {
   
$view = new View();
   
$view->display('home');
});
/**
 * with sub folder
 */
$router->get('/child', function () {
   
$view = new View();
   
$view->display('child/hello.html');
});
/**
 * with an other root folder
 */
$router->get('/other-root', function () {
   
$view = new View();
   
$view->setRoot('/demo');
   
$view->assign('users', [
        [
'name' => 'John Doe'],
        [
'name' => 'Jane Doe']
    ]);
   
$view->display('users.php');
});

$router->run();