PHPackages                             swaroopsm/tower - 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. swaroopsm/tower

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

swaroopsm/tower
===============

A light weight helper for simple php templating

0.4(11y ago)4201MITPHPPHP &gt;=5.4

Since Jun 22Pushed 11y agoCompare

[ Source](https://github.com/swaroopsm/tower)[ Packagist](https://packagist.org/packages/swaroopsm/tower)[ RSS](/packages/swaroopsm-tower/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

Tower
=====

[](#tower)

[![Build Status](https://camo.githubusercontent.com/17a92c9289544bc816f0cc33f4614e594ee78f6e1ce44b5fb00c6fdec76a7ad1/68747470733a2f2f7472617669732d63692e6f72672f737761726f6f70736d2f746f7765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/swaroopsm/tower)[![Code Climate](https://camo.githubusercontent.com/1e6a6cd75060e5aeb82e012e472bfcca3ecc22abf430c8ba6aec836ef2f2e004/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f737761726f6f70736d2f746f7765722e706e67)](https://codeclimate.com/github/swaroopsm/tower)[![Latest Stable Version](https://camo.githubusercontent.com/8a62ef4cf508d87c6c2d29d619abb4c4cb7567658412d9a376b30a178e0a324b/68747470733a2f2f706f7365722e707567782e6f72672f737761726f6f70736d2f746f7765722f762f737461626c652e737667)](https://packagist.org/packages/swaroopsm/tower)[![Total Downloads](https://camo.githubusercontent.com/97c33627e53b2f2be20a23eee5362221cba106ed567feb71f18dcf700d9fa1e3/68747470733a2f2f706f7365722e707567782e6f72672f737761726f6f70736d2f746f7765722f646f776e6c6f6164732e737667)](https://packagist.org/packages/swaroopsm/tower)[![Latest Unstable Version](https://camo.githubusercontent.com/53822942dc5508df6938b6238a37d8eb055aaf036607677db2f34cfab552e9af/68747470733a2f2f706f7365722e707567782e6f72672f737761726f6f70736d2f746f7765722f762f756e737461626c652e737667)](https://packagist.org/packages/swaroopsm/tower)[![License](https://camo.githubusercontent.com/0cb593658358140466ad611742094b5a33cdc190899e15789165d42202de9cce/68747470733a2f2f706f7365722e707567782e6f72672f737761726f6f70736d2f746f7765722f6c6963656e73652e737667)](https://packagist.org/packages/swaroopsm/tower)

A light weight helper for simple php templating.

### Why use Tower?

[](#why-use-tower)

If you want to keep your view logic separated from the core code, Tower is for you. Tower is obviously not a full-fledged template engine. Although if you are using a PHP framework like Codeigniter, Laravel etc., Tower is again a bad solution.

Tower is best suited if for small scale web applications, where you may not need a full-fledged framework. If you decide to write a web application using plain PHP, then do check Tower.

### Installing Tower

[](#installing-tower)

Tower is available via composer. Add the following line to your `composer.json` so that Tower is autoloaded into your application.

```
"require": {
  "swaroopsm/tower": "0.3"
}

```

### Using Tower

[](#using-tower)

Tower has a very simple and easy API consisting of a few methods.

#### Instantiate Tower

[](#instantiate-tower)

```
$tower = new Tower();

```

#### Set a template file

[](#set-a-template-file)

Tell Tower which file should be used as the template.

```
// filename: template.php
>

```

```
$tower->setTemplate('template.php');

```

#### Set variables

[](#set-variables)

Tower lets you setup variables that can be used in your template.

```
$tower->set('name', 'Tower');
$tower->set('description', 'A simple template helper');

```

#### Render your template

[](#render-your-template)

Render on your browser.

```
$tower->render();

```

#### Template Layouting

[](#template-layouting)

Tower also lets you add a layout for your templates. This can be useful if for your webpages. Example on using layout in your templates;

```
$tower->setLayout('layout.php');

```

You use the `$yield` to render the template contents in your helper. A more detailed example on using layout is availabe at: [Layout Example](https://github.com/swaroopsm/tower/wiki/Layout-Example)

#### Using Partials

[](#using-partials)

Partials allows you to include templates in other templates thus allowing you to re-use the templates. Refer to the following code in order to set partials for your templates.

```
$tower->partial->set('header', 'header.php');
$tower->partial->set('footer', 'footer.php');

```

And to render these partials in your templates use:

```

Some stuffs here...

```

If you decide to use a different variable for the partial instead of `$partial` use the following:

```
$tower->partial->setPrefix('towerPartial');

```

Now you can do the following:

```

Some stuffs here...

```

Refer here for a [Detailed Example](https://github.com/swaroopsm/tower/wiki/Including-Partials)

### Some Goodies

[](#some-goodies)

Few other extra methods included in Tower.

#### Save to file

[](#save-to-file)

This is useful if you would like to dynamically save contents to a file.

```
$tower->save('filename.txt');

```

#### Examples

[](#examples)

- [Render Template](https://github.com/swaroopsm/tower/wiki/Render-Template)
- [Layout Example](https://github.com/swaroopsm/tower/wiki/Layout-Example)
- [Partials Example](https://github.com/swaroopsm/tower/wiki/Including-Partials)

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Total

4

Last Release

4284d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/898602?v=4)[Swaroop Sethumadhavan](/maintainers/swaroopsm)[@swaroopsm](https://github.com/swaroopsm)

---

Top Contributors

[![swaroopsm](https://avatars.githubusercontent.com/u/898602?v=4)](https://github.com/swaroopsm "swaroopsm (38 commits)")

---

Tags

templatetemplatinglayout

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/swaroopsm-tower/health.svg)

```
[![Health](https://phpackages.com/badges/swaroopsm-tower/health.svg)](https://phpackages.com/packages/swaroopsm-tower)
```

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8379.7M105](/packages/eftec-bladeone)[fenom/fenom

Fenom - excellent template engine for PHP

45196.3k24](/packages/fenom-fenom)[duncan3dc/blade

Use Laravel Blade templates without the full Laravel framework

160507.5k26](/packages/duncan3dc-blade)[eftec/bladeonehtml

The standalone version Blade Template Engine from Laravel in a single php file

1022.8k6](/packages/eftec-bladeonehtml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
