Download the PHP package midorikocak/view without Composer
On this page you can find all versions of the php package midorikocak/view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download midorikocak/view
More information about midorikocak/view
Files in midorikocak/view
Package view
Short Description View is the V in MVC. A small library to include in your MVC projects.
License MIT
Homepage https://github.com/midorikocak/view
Informations about the package view
View
View is the V in MVC. A small library to include in your MVC projects. Allows you to separate presentation layer from the rest of your application.
Note: It's your responsibility to check user inputs. This library just renders templates. Nothing else.
Install
Via Composer
Usage
Let's say you have blog post data like this:
And you want to render an article using template like this:
You can use default FileRenderer to extract your php files with variables. And you can render your plain php files with variables:
This should output rendered html as this with variables rendered:
Note: Extracting variable into runtime can be unsecure.
Plain templates
If you have plain templates with placemarks as {{ someVariable }}
you can use
TemplateRenderer
To render this template using some data:
This should output rendered html as this with variables rendered:
Using Blade Templates
To use Blade templates, use the included BladeRenderer
.
Custom Renderers
To create your own renderer or extend the library with another renderer library, implement RendererInterface
Rendering data objects
If you have data objects that implement a toArray()
method, you can use ViewableTrait
with them.
So in your controllers you can write code like this:
Custom Viewers in data objects
You can change the viewer object of your data object by accessing it with the viewer that you initialized using custom renderer.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Midori Kocak
- All Contributors
License
The MIT License (MIT). Please see License File for more information.