Download the PHP package kiryi/viewyi without Composer
On this page you can find all versions of the php package kiryi/viewyi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package viewyi
Short Description Native PHP view engine for web applications.
License GPL-3.0-or-later
Homepage https://kiryi.net/
Informations about the package viewyi
Kiryi's VIEWYI
A native PHP view engine for web applications.
Installation
Usage
First initialize the engine in one of three possible ways. See Templating.
Constructor Definition
Parameters
config
Optional configuration array or filepath to custom configuration INI file. If nothing is provided, default (config/viewyi.ini) is used (more information).
Method Definition assign
Assigns a variable to the view's data object.
Parameters
key
The variable's key.
value
The variable's value. Can be string, any number, array, bool or null.
Method Definition render
Renders the current view (HTML page). Have to be called before display
.
Parameters
template
The template name to use as render base.
Return Values
Returns the fully rendered view.
Method Definition reset
Resets the view's data object and view object. This helps dealing with large pages and especially in case of nested templates.
Return Values
Returns the current fully rendered view.
Method Definition display
Finally displays the whole HTML page. It is necessary to call render
at least once before. The rendered view is always embeded to the page's HTML body element. display
can only be called once.
Parameters
headTemplate
The template name to embed into the HTML page's head element.
title
The title of the current page set to the HTML page's title element.
Initialization
You have to provide the engine at least three mandatory parameters as well as an optional fourth.
baseUrl
The base URL of your web application.
imagePath
The image directory path relative to your base URL.
templateDirectory
The template directory path relative to your project's root directory.
templateFileExtension (optional)
Optional file extension of your template files, if you want to use something else than the default .php
.
The parameters can be provided by using the standard configuration file {PROJECTSROOTDIRECTORY}/config/viewyi.ini
with the following contents:
Or by passing another INI file path to the engines's constructor with the same contents. The path has to be relative to your project's root directory:
Or by passing an array with the three to four parameters to the constructor:
Templating
- Use native PHP templates.
- Therefore you may use any PHP alternative syntax control structure.
- Print any data you have assigned by writing
<?=$d->{YOURVARIABLEKEY}?>
. - Build links with your base URL by writing
<a href='<?=$a>{YOURLINKRELATIVETOBASEURL}'>{LINKTEXT}<a>
. - Include images by writing
<img src='<?=$i?>{YOURIMAGEINYOURIMAGEDIRECTORY}' />
.
Example
configuration/config.ini
src/View/head.tpl.php
src/View/home.tpl.php
src/Controller/HomeController.php
will generate the HTML5 page: