Download the PHP package popphp/pop-view without Composer
On this page you can find all versions of the php package popphp/pop-view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download popphp/pop-view
More information about popphp/pop-view
Files in popphp/pop-view
Package pop-view
Short Description Pop View Component for Pop PHP Framework
License BSD-3-Clause
Homepage https://github.com/popphp/pop-view
Informations about the package pop-view
pop-view
- Overview
- Install
- Quickstart
- File Template
- Stream Template
- Includes
- Inheritance
- Iteration
- Conditionals
Overview
pop-view
is the view template component that can be used as the "V" in an MVC stack or
independently as well. It supports using both PHP-file based templates and stream templates.
Within the stream templates, there is basic support for logic and iteration for dynamic
control over the view template.
pop-view
is a component of the Pop PHP Framework.
Top
Install
Install pop-view
using Composer.
composer require popphp/pop-view
Or, require it in your composer.json file
"require": {
"popphp/pop-view" : "^4.0.2"
}
Top
Quickstart
Consider a phtml
template file like this:
You can set up a view object and populate data like this:
which will produce:
Top
File Template
A file template simply uses PHP variables to deliver the data and content to template to be rendered. With a file template, you have full access to the PHP environment to write any additional code or helper scripts. However, in using this, you must make sure to adhere to the best practices and standards regarding the security of the application.
hello.phtml
You can set up the view object like this:
Top
Stream Template
A stream template uses a formatted string placeholder to deliver the data and content to template to be rendered:
hello.html
You can set up the view object in a similar way and it will render the exact same as the file template example.
Top
Includes
Stream templates support includes to allow you to include other templates within them.
header.html
footer.html
index.html
You can set up the view object like before:
Top
Inheritance
Stream templates support inheritance to allow you to extend other templates.
parent.html
child.html
You can set up the view object like before:
Top
Iteration
Iteration is possible in stream templates when working with arrays and array-like objects.
Top
Conditionals
Conditional logic is possible within a stream template as well.
Top