PHPackages                             devtheorem/php-handlebars-parser - 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. devtheorem/php-handlebars-parser

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

devtheorem/php-handlebars-parser
================================

Parse Handlebars templates to a spec-compliant AST with PHP.

v2.1.1(2mo ago)317.9k↑958.9%1MITPHPPHP &gt;=8.2CI passing

Since Feb 20Pushed 2d ago1 watchersCompare

[ Source](https://github.com/devtheorem/php-handlebars-parser)[ Packagist](https://packagist.org/packages/devtheorem/php-handlebars-parser)[ RSS](/packages/devtheorem-php-handlebars-parser/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (15)Versions (8)Used By (1)

PHP Handlebars Parser
=====================

[](#php-handlebars-parser)

Parse [Handlebars](https://handlebarsjs.com) templates to a spec-compliant AST with PHP.

Implements the same lexical analysis and grammar specification as Handlebars.js, so any template which can (or cannot) be parsed by Handlebars.js should parse (or error) the same way here.

Note

This project is only a parser. To compile Handlebars templates to native PHP for execution, see [PHP Handlebars](https://github.com/devtheorem/php-handlebars), which uses this parser.

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

[](#installation)

`composer require devtheorem/php-handlebars-parser`

Usage
-----

[](#usage)

```
use DevTheorem\HandlebarsParser\ParserFactory;

$parser = (new ParserFactory())->create();

$template = "Hello {{name}}!";

$result = $parser->parse($template);
```

If the template contains invalid syntax, an exception will be thrown. Otherwise, `$result` will contain a `DevTheorem\HandlebarsParser\Ast\Program` instance.

Whitespace handling
-------------------

[](#whitespace-handling)

The `ignoreStandalone` Handlebars compilation option can be passed to `parse()`:

```
$result = $parser->parse($template, ignoreStandalone: true);
```

Author
------

[](#author)

Theodore Brown

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance94

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

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

Total

7

Last Release

65d ago

Major Versions

v1.1.2 → v2.0.02026-04-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3053271?v=4)[Theodore Brown](/maintainers/theodorejb)[@theodorejb](https://github.com/theodorejb)

---

Top Contributors

[![theodorejb](https://avatars.githubusercontent.com/u/3053271?v=4)](https://github.com/theodorejb "theodorejb (47 commits)")

---

Tags

handlebarsparserphpphptemplateparseasthandlebars

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devtheorem-php-handlebars-parser/health.svg)

```
[![Health](https://phpackages.com/badges/devtheorem-php-handlebars-parser/health.svg)](https://phpackages.com/packages/devtheorem-php-handlebars-parser)
```

###  Alternatives

[zordius/lightncandy

An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ).

61011.1M54](/packages/zordius-lightncandy)[devtheorem/php-handlebars

A blazing fast, spec-compliant PHP implementation of Handlebars.

4048.6k7](/packages/devtheorem-php-handlebars)

PHPackages © 2026

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