Download the PHP package bephp/microtpl without Composer

On this page you can find all versions of the php package bephp/microtpl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package microtpl

MicroTpl

MicroTpl is small templating system for PHP.

Install

composer require bephp/microtpl 

There is one Blog demo, work with ActiveRecord and Router.

Example

layout.

<!DOCTYPE html>
<html>
  <head>
    <title class="title" tal:content="$title">title place holder</title>
  </head>
  <body>
    <h1 tal:content="$title">title place holder</h1>
    <hr/>
    <div tal:replace="$content">Contents</div>
  </body>
</html>

output layout.htmlc

<!DOCTYPE html>
<html>
  <head>
    <title class="title"></title>
  </head>
  <body>
    <h1></h1>
    <hr></hr>

  </body>
</html>

index.html

<div id="content">
    <div id="menu">
        <ul tal:condition="isset($messages)">
            <li tal:repeat="$messages as $key => $message" >
                <a href="#message-1" tal:content="$message['title']" tal:href="'#message-'.($key+1)">message1</a>
            </li>
            <li tal:replace="">
                <a href="#message-2">message2</a>
            </li>
        </ul>
    </div>
    <div id="message" tal:condition="isset($messages)">
        <div id="message-1" tal:id="'message-'.($key+1)" tal:repeat="$messages as $key => $message" tal:class="($key%2 ? 'odd' : 'even')" >
            <h2>Message #<span tal:replace="$key+1"> 1</span></h2>
            <pre tal:content="$message['content']">message1 place holder</pre>
        </div>
        <div id="message-2" tal:replace="">
            <h2>message # 2</h2>
            <pre>message2 place holder</pre>
        </div>
    </div>
</div>   

output index.htmlc

<div id="content">
    <div id="menu">
        <ul>
            <li>
                <a href=""></a>
            </li>

        </ul>
    </div>
    <div id="message">
        <div id="" class="">
            <h2>Message #</h2>
            <pre></pre>
        </div>

    </div>
</div>

index.php

<?php
include "MicroTpl.php";

$content = <<<STRING
small template attribute language implement for PHP (using xml_parse)
small template attribute language implement for PHP (using xml_parse)
small template attribute language implement for PHP (using xml_parse)
small template attribute language implement for PHP (using xml_parse)
small template attribute language implement for PHP (using xml_parse)
STRING
;
MicroTpl::render('index.html', array(
    'title' => 'Hello Micro Template', 
    'messages' => array(
        array('title' => 'message 1', 'content' => $content),
        array('title' => 'message 2', 'content' => $content),
        array('title' => 'message 3', 'content' => $content),
        array('title' => 'message 4', 'content' => $content),
        array('title' => 'message 5', 'content' => $content),
        array('title' => 'message 6', 'content' => $content),
        array('title' => 'message 7', 'content' => $content),
        array('title' => 'message 8', 'content' => $content),
        array('title' => 'message 9', 'content' => $content),
        array('title' => 'message 10', 'content' => $content)
    )
), 'layout.html');

Syntax

tal:content="$title"
tal:condition="isset($messages)"    
tal:repeat="$messages as $key => $message"
tal:replace=""
/**
 * Replace the attributes of the tag with php code. 
 * Can using the attribute names such as 'id', 'href', 'class' and so on.
 */
tal:id="'message-'.($key+1)"
tal:href="'#message-'.($key+1)"
tal:class="($key%2 ? 'odd' : 'even')" 
......

API refrence

// parse the template from string 
public static function parse($template)
//  render file with layout by using $data.
public static function render($view, $data = array(), $layout = '') 

All versions of microtpl with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bephp/microtpl contains the following files

Loading the files please wait ....