PHPackages                             barefootjs/php - 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. barefootjs/php

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

barefootjs/php
==============

Engine-agnostic PHP runtime for BarefootJS -- the shared BarefootJS.php runtime the Twig, Blade, and other PHP engine adapters bind as a pluggable backend.

v0.31.5(1w ago)0141↓55%2MITPHP &gt;=8.2

Since Jul 8Compare

[ Source](https://github.com/piconic-ai/barefootjs-php)[ Packagist](https://packagist.org/packages/barefootjs/php)[ RSS](/packages/barefootjs-php/feed)WikiDiscussions Synced 1w ago

READMEChangelogDependenciesVersions (36)Used By (2)

@barefootjs/php
===============

[](#barefootjsphp)

The engine-agnostic **PHP runtime** for [BarefootJS](https://barefootjs.dev) — the `BarefootJS` class (`BarefootJS.php`) that compiled marked templates call as the `bf` object (`bf.json(...)`, `bf.spread_attrs(...)`, the array/string method helpers, hydration markers, child-component rendering).

This package has **no dependencies** beyond core PHP (&gt;=8.2). Everything that depends on *how* a template is rendered — JSON marshalling, raw-string marking, JSX-children materialisation, named-template rendering, and template-variable-name mangling — is delegated to a pluggable **backend**, so the same runtime can drive any PHP template engine (Twig, Blade, ...).

```
JSX → IR → (compile-time adapter) → marked template ─┐
                                                      ├─► rendered by the host's
  BarefootJS runtime ── backend ── template engine ───┘    template engine

```

Backend contract
----------------

[](#backend-contract)

A backend implements five methods:

MethodPurpose`encode_json($data)`JSON-encode a value (injectable; defaults to `Barefoot\Json::canonicalEncode`)`mark_raw($str)`Mark a string so the engine emits it without re-escaping`materialize($value)`Resolve a captured-children value to a string`render_named($name, $bf, $vars)`Render a named template with `$bf` bound`ident($name)`Mangle a template-variable name for this engine's reserved-word setInject a backend with `new BarefootJS($c, ['backend' => $backend])`.

Reference implementation
------------------------

[](#reference-implementation)

[`@barefootjs/twig`](../adapter-twig) provides `Barefoot\TwigBackend`(targeting `twig/twig`) plus the compile-time adapter that emits Twig templates (`.twig`).

Composer
--------

[](#composer)

The Packagist distribution name is `barefootjs/php`. The npm package ships the same `src/` so the monorepo integrations can consume it without a separate install.

This package is maintained in the BarefootJS monorepo and is mirrored to a Packagist-facing repository only for Composer distribution.

- Source of truth:
- Monorepo:
- npm package: `@barefootjs/php`
- Composer package: `barefootjs/php`

Do not send implementation pull requests to the Packagist mirror. Send changes to the monorepo path above; the release workflow splits this directory and pushes the mirror automatically.

Tests
-----

[](#tests)

```
php tests/run.php
```

Zero-dependency, PHPUnit-free TAP-ish harness (`tests/_harness.php`). Every `test_*.php` file is also independently runnable via `php tests/test_foo.php`. Includes the golden helper-vector (`test_helper_vectors.php`) and ParsedExpr-evaluator (`test_eval_vectors.php`) conformance suites — see `spec/template-helpers.md`.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance98

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Total

35

Last Release

13d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/117d4ea26adf7bef9f927827a04bb085bbced6aa5e0bd63464c334c5c71a49e3?d=identicon)[kfly8](/maintainers/kfly8)

### Embed Badge

![Health badge](/badges/barefootjs-php/health.svg)

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3841.2M](/packages/limenius-react-bundle)[pdewit/nova-external-url

An external URL Laravel Nova field.

30383.2k](/packages/pdewit-nova-external-url)[wbrowar/guide

A CMS Guide for Craft CMS.

6154.7k1](/packages/wbrowar-guide)[localgovdrupal/localgov_base

The base theme for LocalGov Drupal websites.

13126.9k5](/packages/localgovdrupal-localgov-base)

PHPackages © 2026

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