PHP code example of davidecesarano / embryo-view

1. Go to this page and download the library: Download davidecesarano/embryo-view library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

davidecesarano / embryo-view example snippets


use Embryo\Http\Emitter\Emitter;
use Embryo\Http\Factory\{ResponseFactory, StreamFactory};
use Embryo\View\View;

$response      = (new ResponseFactory)->createResponse(200);
$templatePath  = __DIR__.DIRECTORY_SEPARATOR.'views';
$compilerPath  = __DIR__.DIRECTORY_SEPARATOR.'compilers';
$view          = new View($templatePath, $compilerPath);

$response = $view->render($response, 'page', ['message' => 'Hello World!', 'status' => 1]);

$emitter = new Emitter;
$emitter->emit($response);

$response = $view->render($response, 'home', ['title' => 'Hello World!']);
html
<!-- home.php -->
@itle }}</h1>
    
    </body>
</html>

{{ $name }} // echo htmlentites($name)

{{{ $html }}} // echo $html

@{{ myVar }} // echo {{ myVar }}

@php 
    $a = 1;
    echo  $a; 
@endphp