PHP code example of tpawl / lite

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

    

tpawl / lite example snippets


$settings = [
    $template, // a string holding the template
    ['the' => 'variables', 'go' => 'here'],
    '/path/to/view_helpers',
    'view_helpers\namespace',
];

$templateExpression = new TPawl\LiTE\Expressions\TemplateExpression($settings);

$templateExpression->display();


// HelloViewHelper.php

class HelloViewHelper implements TPawl\LiTE\ViewHelperInterface
{
    public static function execute(array $arguments): void
    {
        print 'Hello world.';
    }
}


use TPawl\LiTE\Expressions\SubTemplateExpression;

class ExampleViewHelper implements TPawl\LiTE\ViewHelperInterface
{
    public static function execute(array $arguments): void
    {
        $condition = $arguments[0];

        if ($condition) {

            $subTemplateExpression = new SubTemplateExpression(
                $templateA, ['the' => 'variables', 'go' => 'here']);

            $subTemplateExpression->display();

        } else {

            $subTemplateExpression = new SubTemplateExpression(
                $templateB, ['the' => 'variables', 'go' => 'here']);

            $subTemplateExpression->display();
        }
    }
}

use TPawl\LiTE\PackageInformations;

echo 'Powered by ', PackageInformations::PACKAGE_NAME , ' ', PackageInformations::makePackageVersionString();

echo 'Copyright &copy; ', PackageInformations::PACKAGE_COPYRIGHT['years'], ' by ', PackageInformations::makePackageCopyrightHoldersString();



class MsgViewHelper implements TPawl\LiTE\ViewHelperInterface
{
    public static function execute(array $arguments): void
    {
        if (version_compare(PHP_VERSION, '7.1.0') >= 0) {

            $msg = 'Everything is fine';

        } else {

            $msg = 'This is not good';
        }
        print $msg;
    }
}




late = <<<'HTML'
<!DOCTYPE html>
Hello  $this->name; 

 $this->foo; 

 self::bar(); 

 self::_xml('version="1.0" encoding="UTF-8" standalone="yes"'); 
 self::bar('arg1', 'arg2', ...);