PHPackages                             millancore/pesto - 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. millancore/pesto

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

millancore/pesto
================

PHP View Engine

v0.1.9(1mo ago)23332[1 PRs](https://github.com/millancore/pesto/pulls)MITPHPPHP ^8.4CI passing

Since Aug 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/millancore/pesto)[ Packagist](https://packagist.org/packages/millancore/pesto)[ GitHub Sponsors](https://github.com/millancore)[ RSS](/packages/millancore-pesto/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (7)Used By (0)

Pesto
=====

[](#pesto)

Modern PHP template engine that provides an intuitive and expressive way to build web application views. It offers a clean syntax using custom HTML attributes and supports advanced templating features like view composition, slots, conditional rendering, loops, and built-in security measures.

Pesto understands the context of `{{ variables }}`and escapes them according to their scope to avoid [Cross-Site Scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) (XSS) issues.

```

    Item {{ $number }}

```

Or, for greater clarity, use ``, which will not be included in the final render.

```

       Item {{ $number }}

```

Pesto templates support files with the `.html` or `.php` extension, allowing you to integrate PHP code if needed.

- [Installation &amp; usage](#installation--usage)
- [View Composition](#view-composition)
    - [The `` Tag](#template-tag)
    - [Partials](#partials--slots)
    - [Slots](#partials--slots)
    - [Nested Views](#nested-views)
- [Control Flow](#control-flow)
    - [If Attribute](#if-attribute)
    - [Loop](#loops)
    - [Inline](#inline)
- [Filters](#filters)
    - [Chain Filters](#chain-filters)
    - [Filters with Arguments](#filters-with-arguments)
    - [Add Filters](#add-filters)
- [Benchmarks](#benchmarks)

Installation &amp; Usage
------------------------

[](#installation--usage)

- PHP ^8.4

Pesto is available via Composer and is free of third-party dependencies

```
composer require millancore/pesto
```

```
use MillanCore\Pesto\PestoFactory;

$pesto = PestoFactory::create([
    templatesPath: __DIR__ . '/views',
    cachePath: __DIR__ . '/cache',
    // [ New CustomFilters(), ... ]
]);

$pesto->make('view.php', ['user' => $user]);
```

View Composition
----------------

[](#view-composition)

Pesto makes it easy to reuse parts of your views

### Template Tag

[](#template-tag)

The `` tag allows you to define php-\* attributes that will be evaluated but not the tag included in the final render.

- `Admin` --&gt; `Admin`
- `Admin` --&gt; `Admin`

### Partials &amp; Slots

[](#partials--slots)

When working with views that are composed of other views, you can use partials and slots to avoid repetition.

Layout

```

>

    {{ $title }}

    {{ $header | slot }}

    {{ $main | slot }}

```

View:

```

        Home
        About

        Home
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quae.

    Item

            nested item
            ....

```

Control Flow
------------

[](#control-flow)

Pesto provides two control flow directives: `foreach` and `if`, enough to build any kind of view.

### If Attribute

[](#if-attribute)

The only rule importance for use `php-elseif` and `php-else` is the tag must be a sibling of the `php-if` tag.

- `php-if`
- `php-elseif`
- `php-else`

`php-if` allows you to conditionally render a block of code.

```
Admin
Moderator
Guest
```

### Loops

[](#loops)

Pesto provides a simple way to loop over arrays or objects.

```
{{ $item }}
```

### Inline

[](#inline)

Pesto also allows you to use inline control flow directives.

```

      {{ $user->name | title }} - {{ $user->email }}

```

Filters
-------

[](#filters)

Pesto provides a simple way to apply filters to variables using the pipe operator, you can define your own filters.

```
{{ $text | upper }}
```

### List of Filters

[](#list-of-filters)

- `raw` Prevents escaping of the variable.

#### String Filters

[](#string-filters)

- `upper`
- `lower`
- `capitalize`
- `title`
- `trim`
- `nl2br`
- `strip_tags`
- `slug`
- `join`

### Chain Filters

[](#chain-filters)

You can chain multiple filters together.

```
{{ $text | capitalize | truncate:50,... }}
```

### Filters with Arguments

[](#filters-with-arguments)

To pass arguments to a filter, you can use the `:` operator.

```
{{ $createAt | date:'m-d-Y' }}
```

### Add Filters

[](#add-filters)

Add filter to Pesto is very simple, you can create a class with public methods and add the AsFilter Attribute.

```
// CustomFilter.php
#[AsFilter(name: 'truncate')]
public function truncate(string $value, int $length, string $end = '...') : string
{
    //...
}
```

on Pesto factory pass the class to the `filters` option.

```
$pesto = PestoFactory::create([
    templatesPath: __DIR__ . '/views',
    cachePath: __DIR__ . '/cache', [
        New CustomFilter(),
    ]
]);
```

Benchmarks
----------

[](#benchmarks)

Pesto includes benchmarks comparing performance against Blade and Twig across four scenarios: simple rendering, loops, conditionals, and partials.

Benchmarks are powered by [PHPBench](https://phpbench.readthedocs.io/) with 100 iterations, 10 revolutions, and 5 warmup iterations.

```
# Run all benchmarks (Pesto, Blade, Twig)
composer bench

# Run a single engine
composer bench:pesto
composer bench:blade
composer bench:twig

# Generate an interactive HTML chart (output: benchmarks/chart.html)
composer bench:chart
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance98

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

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 ~55 days

Total

5

Last Release

38d ago

### Community

Maintainers

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

---

Top Contributors

[![millancore](https://avatars.githubusercontent.com/u/1243194?v=4)](https://github.com/millancore "millancore (41 commits)")

---

Tags

enginephptemplatesview

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/millancore-pesto/health.svg)

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M290](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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