Overview

Namespaces

  • emyu10
    • PhpView

Classes

  • Renderer

Exceptions

  • FileNotFoundException
  • Overview
  • Namespace
  • Class

Class Renderer

This class renders php files as views.

Normally, echoes out the whole file evaluating any variables passed. But it will return the content of the file as a string if an optional $return parameter is true.

Namespace: emyu10\PhpView
Author: Mohamed Usman emyu10@gmail.com
Version: 1
Since: 2018-03-01
Located at Renderer.php
Methods summary
public static string|
# staticRender( string $path, string $file, array $data = null, boolean $return = false )

Initializes all the properties in a single call and then renders the view file by evaluating variables and expressions.

Initializes all the properties in a single call and then renders the view file by evaluating variables and expressions.

If the $return property is true, the method returns the file as a string. Throws \emyu10\PhpView\FileNotFoundException if the view file is not found.

Parameters

$path
the path
$file
the name of the file
$data
the data to be passed
$return

Returns

string|

Throws

emyu10\PhpView\FileNotFoundException
public
# initialize( string $path, string $file, array $data = null, boolean $return = false )

Initialize all the properties in a single call.

Initialize all the properties in a single call.

Use this method to set all the properties in a single call instead of setPath(), setFile(), setData(), setReturn() methods individually.

Parameters

$path
the path
$file
the name of the file
$data
the data to be passed
$return
public
# setPath( string $path )

Sets the absolute path to the view file without the file name.

Sets the absolute path to the view file without the file name.

Parameters

$path
the path
public
# setFile( string $file )

Sets the file name without the file extension. File extension is assumed .php

Sets the file name without the file extension. File extension is assumed .php

Parameters

$file
the name of the file
public
# setData( array $data = null )

Sets any data that need to be passed as an associative array.

Sets any data that need to be passed as an associative array.

The keys become actual variables in the view file.

Parameters

$data
the data to be passed
public
# setReturn( boolean $return )

Sets whether to echo out the file or to return the contents of the file as a string. Default is to echo the file to the output stream.

Sets whether to echo out the file or to return the contents of the file as a string. Default is to echo the file to the output stream.

Parameters

$return
public string|
# render( )

Renders the view file by evaluating variables and expressions. If the $return property is true, the method returns the file as a string.

Renders the view file by evaluating variables and expressions. If the $return property is true, the method returns the file as a string.

Throws \emyu10\PhpView\FileNotFoundException if the view file is not found.

Returns

string|

Throws

emyu10\PhpView\FileNotFoundException
API documentation generated by ApiGen