PHP code example of phpdevcommunity / template-bridge

1. Go to this page and download the library: Download phpdevcommunity/template-bridge 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/ */

    

phpdevcommunity / template-bridge example snippets


use PhpDevCommunity\TemplateBridge\Renderer\PhpRenderer;

// Specify the template directory
$templateDir = '/path/to/templates';

// Optional parameters to be passed to the templates
$parameters = [
    'siteTitle' => 'My Website',
];

// Create the renderer instance
$renderer = new PhpRenderer($templateDir, $parameters);

 $this->extend('layout.php'); 

<!DOCTYPE html>
<html>
<head>
    <title> echo $this->block('title'); 

echo $renderer->render('template.php', ['name' => 'John']);

// Get a parameter value
$siteTitle = $this->get('siteTitle');