PHPackages                             getphred/scape - 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. getphred/scape

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

getphred/scape
==============

A Lightweight PHP Template Engine

01PHP

Since Feb 12Pushed 4mo agoCompare

[ Source](https://github.com/getphred/scape)[ Packagist](https://packagist.org/packages/getphred/scape)[ RSS](/packages/getphred-scape/feed)WikiDiscussions master Synced 1mo ago

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

Scape Templates
===============

[](#scape-templates)

[![Latest Version on Packagist](https://camo.githubusercontent.com/892a274400b83fa12149d9146228bc0d999722a32e25bcc6e72dfc44dfe3908c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67657470687265642f73636170652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/getphred/scape)[![Total Downloads](https://camo.githubusercontent.com/857eea87cc14d9c5ffba1c7eca6c80448693a99c16e1e223396eea51882be6a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67657470687265642f73636170652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/getphred/scape)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A lightweight, standalone PHP template engine designed for simplicity, security, and performance. Scape focuses on being an **Output Engine first**, marrying pre-processed data with design while enforcing a "logic-light" philosophy.

Features
--------

[](#features)

- **Dot Notation &amp; Bracket Access**: Effortlessly access nested objects and arrays.
- **Inheritance &amp; Blocks**: Define base layouts and override sections in child templates.
- **Partials &amp; Includes**: Reuse template snippets with controlled data scoping.
- **Filter Pipeline**: Transform data using built-in or custom filters (e.g., `{{ var | lower | ucfirst }}`).
    - Built-in filters: `lower`, `upper`, `ucfirst`, `currency`, `float`, `date`, `truncate`, `default`, `json`, `url_encode`, `join`, `first`, `last`, `word_count`, `keys`.
    - Filters can be used in variable interpolations, `foreach` loops, and `include` tags.
- **Secure by Default**: Automatic contextual HTML escaping for all variables.
- **AST Caching**: High performance via Abstract Syntax Tree caching with automatic dev-mode invalidation.
- **Host Integration (IoC)**: Easy integration with frameworks through the reserved `host` namespace.
- **Logic-Light**: Encourages separation of concerns by supporting only necessary logic like `foreach`.

Installation
------------

[](#installation)

```
composer require getphred/scape
```

Quick Start
-----------

[](#quick-start)

```
use Scape\Engine;

$engine = new Engine([
    'templates_dir' => __DIR__ . '/templates',
    'mode' => 'debug' // or 'production'
]);

echo $engine->render('index', [
    'title' => 'Welcome to Scape',
    'user' => ['name' => 'Funky']
]);
```

### Basic Syntax

[](#basic-syntax)

#### Interpolation (Escaped)

[](#interpolation-escaped)

`{{ user.name }}`

#### Raw Interpolation

[](#raw-interpolation)

`{{{ raw_html }}}`

#### Loops

[](#loops)

```
{( foreach item in items )}
    {{ item }}
{( endforeach )}
```

#### Filtering

[](#filtering)

`{{ price | currency('USD') }}`

#### Advanced Expressions

[](#advanced-expressions)

`{( foreach key in user_data | keys )}`

`{[ include 'partial' with data | first ]}`

#### Inheritance

[](#inheritance)

`layout.scape.php`:

```

    {[ block 'title' ]}Default Title{[ endblock ]}
    {[ block 'content' ]}{[ endblock ]}

```

`page.scape.php`:

```
{[ extends 'layout' ]}
{[ block 'title' ]}My Page{[ endblock ]}
{[ block 'content' ]}
    Hello World
{[ endblock ]}
```

Configuration
-------------

[](#configuration)

Scape uses environment variables or programmatic configuration:

- `SCAPE_TEMPLATES_DIR`: Default `./templates`
- `SCAPE_LAYOUTS_DIR`: Default `./templates/layouts`
- `SCAPE_PARTIALS_DIR`: Default `./templates/partials`
- `SCAPE_FILTERS_DIR`: Default `./filters`
- `SCAPE_CACHE_DIR`: Default `./.scape/cache`
- `SCAPE_MODE`: `production` (default) or `debug`

License
-------

[](#license)

MIT

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance51

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

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

143d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76918287c4577d7b4a6713f0d54f3de11e0d6a86f88bb2883b5dd0a19f80d87f?d=identicon)[getphred](/maintainers/getphred)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/getphred-scape/health.svg)

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[ktquez/laravel-tinymce

TinyMCE editor for Laravel and Lumen Framework

2525.4k](/packages/ktquez-laravel-tinymce)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.3k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

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