@barefootjs/php 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @barefootjs/php
2
+
3
+ The engine-agnostic **PHP runtime** for [BarefootJS](https://barefootjs.dev) —
4
+ the `BarefootJS` class (`BarefootJS.php`) that compiled marked templates call
5
+ as the `bf` object (`bf.json(...)`, `bf.spread_attrs(...)`, the array/string
6
+ method helpers, hydration markers, child-component rendering).
7
+
8
+ This package has **no dependencies** beyond core PHP (>=8.2). Everything that
9
+ depends on *how* a template is rendered — JSON marshalling, raw-string
10
+ marking, JSX-children materialisation, named-template rendering, and
11
+ template-variable-name mangling — is delegated to a pluggable **backend**, so
12
+ the same runtime can drive any PHP template engine (Twig, Blade, ...).
13
+
14
+ ```
15
+ JSX → IR → (compile-time adapter) → marked template ─┐
16
+ ├─► rendered by the host's
17
+ BarefootJS runtime ── backend ── template engine ───┘ template engine
18
+ ```
19
+
20
+ ## Backend contract
21
+
22
+ A backend implements five methods:
23
+
24
+ | Method | Purpose |
25
+ |--------|---------|
26
+ | `encode_json($data)` | JSON-encode a value (injectable; defaults to `Barefoot\Json::canonicalEncode`) |
27
+ | `mark_raw($str)` | Mark a string so the engine emits it without re-escaping |
28
+ | `materialize($value)` | Resolve a captured-children value to a string |
29
+ | `render_named($name, $bf, $vars)` | Render a named template with `$bf` bound |
30
+ | `ident($name)` | Mangle a template-variable name for this engine's reserved-word set |
31
+
32
+ Inject a backend with `new BarefootJS($c, ['backend' => $backend])`.
33
+
34
+ ## Reference implementation
35
+
36
+ [`@barefootjs/twig`](../adapter-twig) provides `Barefoot\TwigBackend`
37
+ (targeting `twig/twig`) plus the compile-time adapter that emits Twig
38
+ templates (`.twig`).
39
+
40
+ ## Composer
41
+
42
+ The Packagist distribution name is `barefootjs/php`. The npm package
43
+ ships the same `src/` so the monorepo integrations can consume it without a
44
+ separate install.
45
+
46
+
47
+ This package is maintained in the BarefootJS monorepo and is mirrored to a
48
+ Packagist-facing repository only for Composer distribution.
49
+
50
+ - Source of truth: <https://github.com/piconic-ai/barefootjs/tree/main/packages/adapter-php>
51
+ - Monorepo: <https://github.com/piconic-ai/barefootjs>
52
+ - npm package: `@barefootjs/php`
53
+ - Composer package: `barefootjs/php`
54
+
55
+ Do not send implementation pull requests to the Packagist mirror. Send changes to
56
+ the monorepo path above; the release workflow splits this directory and pushes the
57
+ mirror automatically.
58
+
59
+ ## Tests
60
+
61
+ ```sh
62
+ php tests/run.php
63
+ ```
64
+
65
+ Zero-dependency, PHPUnit-free TAP-ish harness (`tests/_harness.php`). Every
66
+ `test_*.php` file is also independently runnable via `php tests/test_foo.php`.
67
+ Includes the golden helper-vector (`test_helper_vectors.php`) and
68
+ ParsedExpr-evaluator (`test_eval_vectors.php`) conformance suites — see
69
+ `spec/template-helpers.md`.
package/composer.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "barefootjs/php",
3
+ "description": "Engine-agnostic PHP runtime for BarefootJS -- the shared BarefootJS.php runtime the Twig, Blade, and other PHP engine adapters bind as a pluggable backend.",
4
+ "type": "library",
5
+ "license": "MIT",
6
+ "authors": [
7
+ {
8
+ "name": "kobaken",
9
+ "email": "kentafly88@gmail.com"
10
+ }
11
+ ],
12
+ "require": {
13
+ "php": ">=8.2"
14
+ },
15
+ "autoload": {
16
+ "psr-4": {
17
+ "Barefoot\\": "src/"
18
+ }
19
+ },
20
+ "minimum-stability": "stable"
21
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@barefootjs/php",
3
+ "version": "0.1.0",
4
+ "description": "BarefootJS engine-agnostic PHP runtime -- pluggable rendering backend; the shared basis for Twig, Blade and other PHP engine integrations",
5
+ "type": "module",
6
+ "files": [
7
+ "src",
8
+ "tests",
9
+ "composer.json",
10
+ "README.md"
11
+ ],
12
+ "keywords": [
13
+ "php",
14
+ "barefoot",
15
+ "ssr",
16
+ "runtime",
17
+ "template"
18
+ ],
19
+ "author": "kobaken <kentafly88@gmail.com>",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/piconic-ai/barefootjs",
24
+ "directory": "packages/adapter-php"
25
+ }
26
+ }