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.

v1.1.1(1mo ago)31.2k↑154.2%1MITPHPPHP &gt;=8.2CI passing

Since Feb 20Pushed 1mo 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 1mo ago

READMEChangelog (3)Dependencies (10)Versions (4)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 parser can be created with an optional boolean argument, to support the `ignoreStandalone` Handlebars compilation option:

```
$parser = (new ParserFactory())->create(ignoreStandalone: true);
```

Author
------

[](#author)

Theodore Brown

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

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

Total

3

Last Release

56d ago

### 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 (29 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/ ).

60910.5M45](/packages/zordius-lightncandy)[devtheorem/php-handlebars

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

1924.8k2](/packages/devtheorem-php-handlebars)

PHPackages © 2026

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