2017 © Pedro Peláez
 

library raw-php-view

A minimal php view service for raw php

image

jibundeyare/raw-php-view

A minimal php view service for raw php

  • Wednesday, December 13, 2017
  • by jibundeyare
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

RawPhpView

A minimal php view service for raw php, (*1)

install

Open a terminal, go to your project directory and type:, (*2)

composer require jibundeyare/raw-php-view

views directory

It is recommended to create a separate directory to store the views., (*3)

In the examples, we use the following directory structure:, (*4)

project/
  public/
    index.php
  templates/
    hello.php
  vendor/

usage

Create a PHP template file templates/hello.php :, (*5)

<!-- templates/hello.php -->
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title><?php echo $greeting; ?></title>
    </head>
    <body>
        <h1><?php echo $greeting; ?></h1>
    </body>
</html>

Create a PHP script file public/index.php :, (*6)

<?php
// public/index.php

use RawPhpView\ViewService;

require __DIR__.'/../vendor/autload.php';

$path = __DIR__.'/../templates';
$view = new ViewService($path);

$greeting = 'Hello!';

echo $view->render('hello.php', [
    'greeting' => $greeting,
]);

// templates/hello.php
echo $greeting;

In your terminal, start a web server :, (*7)

php -S localhost:8000 -t public

And enjoy the result : http://localhost:8000., (*8)

The Versions

13/12 2017

dev-master

9999999-dev https://github.com/jibundeyare/php-view

A minimal php view service for raw php

  Sources   Download

MIT

by Daishi Kaszer