Download the PHP package davidecesarano/embryo-view without Composer
On this page you can find all versions of the php package davidecesarano/embryo-view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidecesarano/embryo-view
More information about davidecesarano/embryo-view
Files in davidecesarano/embryo-view
Package embryo-view
Short Description A PHP renderer for rendering PHP views in PSR response.
License MIT
Homepage https://github.com/davidecesarano/embryo-view
Informations about the package embryo-view
Embryo View
PHP template engine and renderer for PSR-7 response.
Features
- PSR compatible.
- Alternative syntax.
- Views compiled and cached until they are modified.
- PSR-15 middleware for minify html.
Requirements
- PHP >= 7.1
- A PSR-7 http message implementation and PSR-17 http factory implementation (ex. Embryo-Http)
- A PSR response emitter (ex. Embryo-Emitter)
Installation
Using Composer:
Example
Create Response
object, set views
and compilers
directory, create a View
object. Render view with render()
method passing response, template and data. Finally, emit response.
Usage
Create and render views
If you want create a template with partials file, you can write this:
In this example you can use @include(filename, data)
for include header.php in home.php passing data to file. Embryo View will compile the file by replacing the alternative syntax in PHP code. Finally, you may display page with render:
Display data
You may display the contents of the name variable like so:
If you want display html content use like so:
If you use VueJs mustache templating, you may use like so:
If statements
You may construct if statements using the @if
, @elseif
, @else
, and @endif
directives.
Loops
Embryo View provides simple directives for working with PHP's loop structures (for
, foreach
and while
):
PHP
You can use the @php
directive to execute a block of plain PHP within your template:
All versions of embryo-view with dependencies
davidecesarano/embryo-http Version dev-master
davidecesarano/embryo-emitter Version dev-master
psr/http-server-middleware Version ^1.0