PHPackages                             net\_bazzline/php\_component\_template - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. net\_bazzline/php\_component\_template

ActiveLibrary[Templating &amp; Views](/categories/templating)

net\_bazzline/php\_component\_template
======================================

free as in freedom free software template engine for php

3.1.3(10y ago)1111[1 issues](https://github.com/bazzline/php_component_template/issues)1LGPLv3PHPPHP &gt;=5.3.3

Since Oct 1Pushed 9y ago4 watchersCompare

[ Source](https://github.com/bazzline/php_component_template)[ Packagist](https://packagist.org/packages/net_bazzline/php_component_template)[ RSS](/packages/net-bazzline-php-component-template/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (10)Used By (1)

Template Engine for PHP
=======================

[](#template-engine-for-php)

This project aims to deliver an easy to use, free as in freedom and fast template engine for php (code name: yepte - yet another php template engine).

The build status of the current master branch is tracked by Travis CI: [![Build Status](https://camo.githubusercontent.com/4b587b570f2d2ebd56297ec69d5018f540a308d6f1632cbc7a8ebd243669b91f/68747470733a2f2f7472617669732d63692e6f72672f62617a7a6c696e652f7068705f636f6d706f6e656e745f74656d706c6174652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/bazzline/php_component_template)[![Latest stable](https://camo.githubusercontent.com/0dcb328f71bd722a5d1033eece2cba0ce140e94fe43fa2b903a2720f20fe4f29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65745f62617a7a6c696e652f7068705f636f6d706f6e656e745f74656d706c6174652e737667)](https://packagist.org/packages/net_bazzline/php_component_template)

The scrutinizer status are: [![code quality](https://camo.githubusercontent.com/37520e92e7cc5f9f652381e0c88617a9f814da490f6a0822929eb3cbdea361fd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617a7a6c696e652f7068705f636f6d706f6e656e745f74656d706c6174652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bazzline/php_component_template/)

The versioneye status is: [![Dependency Status](https://camo.githubusercontent.com/2be7fcd511e77acd6e6e3eaa0c12223ee91f37ccb875ce0761c60c355284d367/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3536313831663063623036643530303030393030313366392f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/56181f0cb06d5000090013f9)

Take a look on [openhub.net](https://www.openhub.net/p/php_component_template).

Why
===

[](#why)

I wanted to create a lean (in matter of lines of code and number of files) fast, extendable but expendable template engine for php. This project does not aim to shake on the throne of the big template engine available for php. They have different goals, more manpower and different ideas behind.

Personally, I like the [php-text-template](https://github.com/sebastianbergmann/php-text-template) but sebastian has a different approach in mind (writing something to a file). Adding my goals to his project would add more complexity to his library.

Available Templates
-------------------

[](#available-templates)

Currently, this component tries to solve three problems when dealing with php templates. All Templates are stackable, meaning you can assign one template key with another template instance.

[RuntimeContentBasedTemplate](https://github.com/bazzline/php_component_template/blob/master/source/RuntimeContentBasedTemplate.php) solve the problem to replacing content stored in a string.

[FileBasedTemplate](https://github.com/bazzline/php_component_template/blob/master/source/FileBasedTemplate.php) solves the problem replacing content stored in a file.

[ComplexFileBasedTemplate](https://github.com/bazzline/php_component_template/blob/master/source/ComplexFileBasedTemplate.php) solves the problem replacing complex content stored in a file. This is commonly known as the view in php frameworks.

[CallableComplexFileBasedTemplateManager](https://github.com/bazzline/php_component_template/blob/master/source/CallableComplexFileBasedTemplateManager.php) solves the problem externalise reusable template tasks. This is commonly known as the view helper pattern.

Notes
-----

[](#notes)

### What is a complex content?

[](#what-is-a-complex-content)

Complex content contains code like:

```
$isFoo = ($bar === 'foo');
if ($isFoo) {
     /* ... */
} else {
    /*  ... something else */
}
```

### What is a callable?

[](#what-is-a-callable)

Callable is an other word for the famous view helper design pattern. The template provides a method called "registerCallable" to register a callable and bind it to a name.

```
//assuming the file in the relative path 'template.phtml' has the following content
//
