PHPackages                             walter-a-jablonowski/damn-small-engine - 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. walter-a-jablonowski/damn-small-engine

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

walter-a-jablonowski/damn-small-engine
======================================

PHP low code templating system

v0.1.0(5y ago)241MITPHPPHP &gt;=7.1.9

Since Oct 28Pushed 5y agoCompare

[ Source](https://github.com/walter-a-jablonowski/damn-small-engine)[ Packagist](https://packagist.org/packages/walter-a-jablonowski/damn-small-engine)[ Docs](https://github.com/walter-a-jablonowski/damn-small-engine)[ RSS](/packages/walter-a-jablonowski-damn-small-engine/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Damn Small Engine
=================

[](#damn-small-engine)

**PHP low code templating system - small but powerful**

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Version 0.1 - This was tested using PHP 7.1.9, should run at leat on 7.1.9 and above.
See also: [Migrations](migrations.md) - **some samples still need debuging**

A simple PHP templating system, based on an idea that I saw somewhere on the internet about 2 years ago. Basically, this uses PHP's output buffering and magic methods. It is a truly awesome concept, because the code is so tiny compared to popular templating systems. Use less code, achieve more! You can easily read that small code and modify it for your needs. I improved the basic idea and added some features. Have a look at the very small classes View and ListView files in /src. These are enough (shown in [Basic sample](wiki/Basic_sample.md)), although there are more classes providing features for WebPage and controls ([see samples below](https://github.com/walter-a-jablonowski/damn-small-engine#normal-sample)).

If you like run the sample code in /sample\_normal, /sample\_advanced and /sample\_basic.

```
composer require walter-a-jablonowski/damn-small-engine

```

**Table of contents**

- [Compare it](https://github.com/walter-a-jablonowski/damn-small-engine#compare-it)
- [Features](https://github.com/walter-a-jablonowski/damn-small-engine#features)
- [Normal sample](https://github.com/walter-a-jablonowski/damn-small-engine#normal-sample)
    - also includes samples overview
- [Classes overview](https://github.com/walter-a-jablonowski/damn-small-engine#classes)
- [License](https://github.com/walter-a-jablonowski/damn-small-engine#license)

> If you like visit my personal homepage: [walter-a-jablonowski.github.io](https://walter-a-jablonowski.github.io)

Compare Damn Small Engine
-------------------------

[](#compare-damn-small-engine)

... with popular templating systems:

- [Mustache PHP](https://github.com/bobthecow/mustache.php) (free) - Unusual syntax, could require some learning - but I like that class mapping feature. All logic in code, that's nice. The engine code seems too large, hard to maintain in case there are no updates.
- [Laravel Blade](https://laravel.com/docs/5.8/blade) (free) - Some nice features, but unsure if all of this is really needed. See how much code they [are using](https://github.com/laravel/framework/tree/5.8/src/Illuminate/View) and compare [Damn Small Engine's few classes](src/).

Features
--------

[](#features)

- **Small:** Just 2 small classes for basic use (can easily be modified)
- additional classes providing more features (small compared with third party engines)
- **Build nested views** and/or lists with data
- **Add styles/js** in a `WebPage`
- **Automatically import** component specific styles and js in a web page
    - just add your html block in `WebPage`, the rest will be done by this lib
- This lib is like `$view->subView = new ListView( ... )` (or variations of it)
- **All logic in code!** Template files don't need any control structures (as it should be)
    - Why the heck do people invent a new programming lang in their templating systems while they already have one?!
    - In fact logic in templates ***is possible***, see [misc samples](wiki/Misc_samples.md) (no recommendation)
- You don't have to learn a new syntax =&gt; **no problems fixing syntax bugs**
    - just use PHP's syntax that you know well, you can easily compose your view
- ... and **all PHP language features** are available

**Can't get any updates?** ... for your preferred templating system anymore? Does it have massive codes, maintenance impossible? No problem with Damn Small Engine. This thing is so small, you can easily understand the code and maintain or extend it yourself.

Normal sample
-------------

[](#normal-sample)

**Building a bootstrap 4.3 webpage and table**

❕ There are more samples available

- A much [simpler sample](wiki/Basic_sample.md), that uses only the most basic 2 classes
- [Advanced sample](wiki/Advanced_sample.md): style/js includes, add classes dynamically, dynamic table
- [Component sample](wiki/Component_sample.md): automatically include style and/or js
- [Misc samples](wiki/Misc_samples.md)

This sample

- **Run the code:** /sample\_normal/view.php
- **HTML code see:** /sample\_normal/my\_includes and /sample\_normal/my\_controls

```
// Some config

$config = DSEConfig::instance();

if( $env == DEBUG )     $config->preferMinified( false );  // should use minified version ?
elseif( $env == PROD )  $config->preferMinified( true );

// $config->setControlsFolder('controls/');
$config->setDirPrefix( 'my_' );  // a folder prefix that you can leave out on new View( ... )

// Data

$dbRows = ...

// Build

$page = new WebPage( 'includes/page' );         // looks like hierarchical identifier, is also: a file path
$layout = $page->newView( 'includes/layout' );  //   prefix and type will be added => my_includes/page.html

// Page data

$layout->myValue  = 'My dynamic content 1';
$layout->myValue2 = 'My dynamic content 2';

// Table

$table = $page->newSimpleControl( 'controls/table/view' );  // column headings are hard coded see my_controls/table/view.html
$rows = $page->newListView();        // instead you could use ListView::buildList( ... );
                                     //   for the whole table, see basic sample

foreach( $dbRows as $id => $dbRow )  // if you prefer, you also could use a for loop in
{                                    //   html instead, see "misc samples"
  $row = $page->newView( 'controls/table/row' );

  $row->field1 = $dbRow['col_1'];    // you could also use: $row->setValues( $dbRow );
  $row->field2 = $dbRow['col_2'];

  $rows->addView( $row );
}

$table->addSubView( 'content', $rows );
$layout->addSubView( 'table', $table );
$page->attachContent( $layout );

echo $page->render();
```

### Result

[](#result)

[![normal_sample.jpg](wiki/img/normal_sample_45.jpg?raw=true "Normal sample")](wiki/img/normal_sample_45.jpg?raw=true)

Classes overview
----------------

[](#classes-overview)

 [![](https://camo.githubusercontent.com/fce29c16a82574a700b28ab57bfe0652fdc4354a3b8c8e400f76f8d7d017efa5/68747470733a2f2f79756d6c2e6d652f38326136356635612e706e67)](https://camo.githubusercontent.com/fce29c16a82574a700b28ab57bfe0652fdc4354a3b8c8e400f76f8d7d017efa5/68747470733a2f2f79756d6c2e6d652f38326136356635612e706e67)

**Basic classes**

- **View:** A view (each view or sub view can have sub views)
- **ListView:** A view composed of a list of views

**Feature classes**

- **SimpleControl:** A simple control that uses no style or JS (input, table, ...)
    - basically a synonym for `View`, uses DSEConfig's controlsFolder as additional folder prefix if set
- **WebPage:** Builds a full web page, ability 2 add style, js and components
    - A component is a piece of html that also needs styles and/or javascript
    - This class is able 2 add these in head and body automatically
- **ComponentBase:** Base class for a component that needs style/js includes and contains implementation
    - or include a component using `$webPage->newComponent()` if you don't need implementation

**Common classes**

- **DSEConfig:** Config for Damn Small Engine
- **ViewBase:** Just a simple base class for all view classes

LICENSE
-------

[](#license)

Copyright (C) Walter A. Jablonowski 2018-2019, MIT [License](LICENSE)

This library is build upon PHP (license see [credits](credits.md)) and has no further dependencies.
Licenses of third party software used in samples see [credits](credits.md).

[Privacy](https://walter-a-jablonowski.github.io/privacy.html) | [Legal](https://walter-a-jablonowski.github.io/imprint.html)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

2022d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a980a80c3b5dd7599e7de6ef9a627b5187590d2fcf99e818770ae5dffee92d46?d=identicon)[walterjab](/maintainers/walterjab)

---

Top Contributors

[![walter-a-jablonowski](https://avatars.githubusercontent.com/u/31986246?v=4)](https://github.com/walter-a-jablonowski "walter-a-jablonowski (82 commits)")

---

Tags

phptemplate-enginetemplate-librarywebpagetemplatetemplatingSimpleeasysmarttinysmallinnovationinnovative

### Embed Badge

![Health badge](/badges/walter-a-jablonowski-damn-small-engine/health.svg)

```
[![Health](https://phpackages.com/badges/walter-a-jablonowski-damn-small-engine/health.svg)](https://phpackages.com/packages/walter-a-jablonowski-damn-small-engine)
```

###  Alternatives

[eftec/bladeone

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

8208.4M87](/packages/eftec-bladeone)[fenom/fenom

Fenom - excellent template engine for PHP

44395.5k19](/packages/fenom-fenom)[duncan3dc/blade

Use Laravel Blade templates without the full Laravel framework

160499.5k24](/packages/duncan3dc-blade)[monotek/minitpl

Miniature fully featured PHP template engine

125.5k1](/packages/monotek-minitpl)[eftec/bladeonehtml

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

1018.1k5](/packages/eftec-bladeonehtml)

PHPackages © 2026

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