PHPackages                             quellabs/canvas-handlebars - 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. quellabs/canvas-handlebars

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

quellabs/canvas-handlebars
==========================

Handlebars template engine integration for the Canvas PHP framework via LightnCandy, with contextual containers and automatic service discovery

1.0.6(3w ago)00MITPHP

Since Mar 26Pushed 3w agoCompare

[ Source](https://github.com/quellabs/canvas-handlebars)[ Packagist](https://packagist.org/packages/quellabs/canvas-handlebars)[ Docs](https://github.com/quellabs/canvas-handlebars)[ RSS](/packages/quellabs-canvas-handlebars/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (18)Versions (8)Used By (0)

Canvas Handlebars Template Engine
=================================

[](#canvas-handlebars-template-engine)

A Handlebars template engine integration for the Canvas PHP framework, powered by [LightnCandy](https://github.com/zordius/lightncandy).

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

[](#installation)

```
composer require quellabs/canvas-handlebars
```

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Canvas framework

How it works
------------

[](#how-it-works)

Unlike output-cache engines (Smarty, Twig), LightnCandy **compiles** Handlebars templates to native PHP closures. The compiled files are stored in `compile_dir` and reused across requests. Recompilation only happens when a source template is newer than its compiled counterpart — no opcode cache invalidation overhead.

Usage
-----

[](#usage)

The Handlebars template engine is automatically registered with Canvas through the service discovery system.

```
class HomeController {
    public function index(TemplateEngineInterface $handlebars) {
        return $handlebars->render('home.hbs', [
            'title' => 'Welcome to Canvas',
            'user'  => $user
        ]);
    }
}
```

Template Files
--------------

[](#template-files)

```
templates/
├── home.hbs
├── layouts/
│   └── app.hbs
└── partials/
    └── header.hbs

```

Helpers
-------

[](#helpers)

Register helpers in `config/handlebars.php`:

```
'helpers' => [
    'uppercase'  => fn($str)  => strtoupper($str),
    'formatDate' => fn($ts)   => date('Y-m-d', $ts),
],
```

Or register them at runtime via the engine instance:

```
$handlebars->registerHelper('uppercase', fn($str) => strtoupper($str));
```

Use in templates:

```
{{uppercase title}}
Published: {{formatDate createdAt}}
```

Partials
--------

[](#partials)

Partials are reusable template fragments. Register them as strings in config or at runtime:

```
$handlebars->registerPartial('header', '{{siteName}}');
```

Use in templates:

```
{{> header}}
{{content}}
```

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

[](#configuration)

KeyDefaultDescription`template_dir``templates/`Where `.hbs` files are stored`compile_dir``storage/handlebars/compile/`Where compiled PHP renderers are cached`strict_mode``false`Throw on missing variables instead of rendering empty`standalone``false`Embed helpers in compiled output (no runtime dependency)`helpers``[]`Named helper callables`partials``[]`Named partial template strings`globals``[]`Variables available in all templatesSculpt Commands
---------------

[](#sculpt-commands)

```
php sculpt handlebars:clear-cache
```

Removes all compiled PHP renderers, forcing recompilation on the next request.

License
-------

[](#license)

MIT License

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance95

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity39

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

Every ~11 days

Total

7

Last Release

25d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57e4ab872b3e37536367f2d26b192df3d3bb6a6a1cebec9a104d14a6d2ffe157?d=identicon)[noescom](/maintainers/noescom)

---

Tags

handlebarslightncandycanvas-frameworktemplate-integrationphp-templating

### Embed Badge

![Health badge](/badges/quellabs-canvas-handlebars/health.svg)

```
[![Health](https://phpackages.com/badges/quellabs-canvas-handlebars/health.svg)](https://phpackages.com/packages/quellabs-canvas-handlebars)
```

###  Alternatives

[proai/laravel-handlebars

A Laravel wrapper for LightnCandy for using the Handlebars (and Mustache) template engine.

38206.9k](/packages/proai-laravel-handlebars)

PHPackages © 2026

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