Skip to content
Mikhail Deynekin edited this page Oct 11, 2026 · 2 revisions

CLI β€” bin/htmlphp & wp htmlphp

One binary for deploys, cron jobs and CI; the same commands inside WordPress through WP-CLI. Library resolution: HTML_PHP_LIB env β†’ vendor/autoload.php β†’ dev autoload.php β†’ the edition-matching bundle.

htmlphp <command> [arguments] [--options]

Global: --config=FILE β€” a PHP file that returns a v4 config array (the same shape Engine::create() takes).

Exit codes: 0 ok Β· 1 lint errors / runtime failure Β· 2 usage error.

Commands

version

$ htmlphp version
5.0.0 (8.3 edition) Β· PHP 8.3.35

config:dump

Effective configuration as JSON β€” every group, enums resolved. The fastest way to see what a --config file actually produced.

lint PATH...

$ htmlphp lint templates/ --format=json --ignore=untranslated-message
templates/card.html:7 ERROR [unknown-filter] Unknown filter "uppr".
2 issue(s), 1 error(s).          # exit code 1
  • files and directories (.html .htm .txt .shtml .xhtml)
  • --format=text|json β€” JSON is pure on stdout (summary goes to stderr), pipe it straight into CI annotations
  • --ignore=code,code baselines known findings
  • 25 issue codes: structure, filters, expressions, includes/layouts, trans blocks, SSI directives/expressions, exec-policy notices β†’ full table

render TEMPLATE [--var k=v]...

Renders a file path or locator name to stdout (--var values are strings; for structured data drive the engine from PHP).

ssi FILE [--root=DIR]

SSI-only pass over a file, anchored at that file, contained by --root.

cache:clear

Empties the configured render cache + the in-memory parse memo.

i18n:extract DIR [--out=FILE] [--ext=html]

@{key} + @Trans blocks β†’ POT skeleton with #: file:line references. Dynamic %{var|translate} usages are reported as warnings on stderr.

i18n:audit DIR [--locale=de] [--domain=messages]

$ htmlphp i18n:audit templates/ --locale=de
Locale de: 41/52 messages translated (79%), 3 unused.
  missing: checkout.total
  unused:  legacy.banner          # exit code 1 (missing > 0)

CI recipes

GitHub Actions β€” lint gate with inline PR annotations

- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
  with: { php-version: '8.3', coverage: none }
- name: Template lint
  run: |
    php bin/htmlphp lint templates/ --format=json > lint.json || true
    php -r '
      $issues = json_decode(file_get_contents("lint.json"), true) ?: [];
      foreach ($issues as $i)
        printf("::%s file=%s,line=%d,title=%s::%s\n",
          $i["severity"] === "error" ? "error" : "warning",
          $i["file"], $i["line"], $i["code"], $i["message"]);
      exit(array_any($issues, fn($i) => $i["severity"] === "error") ? 1 : 0);
    '

(Or use the planned htmlphp/lint@v1 action β€” ROADMAP.)

Release gate β€” translations complete?

- run: php bin/htmlphp i18n:extract templates/ --out=/tmp/messages.pot
- run: php bin/htmlphp i18n:audit templates/ --locale=de --config=config/htmlphp.php
- run: php bin/htmlphp i18n:audit templates/ --locale=fr --config=config/htmlphp.php

Deploy hook β€” warm & verify

php bin/htmlphp lint templates/ && php bin/htmlphp cache:clear

WordPress equivalents

Standalone WP-CLI
htmlphp version wp htmlphp info [--json] (adds WP/server/updates sections)
htmlphp lint … wp htmlphp lint [<path>] (theme roots by default)
htmlphp render … wp htmlphp render <template> [--var=k:v]…
htmlphp cache:clear wp htmlphp cache clear (object cache + transients registry)
htmlphp i18n:extract/audit wp htmlphp i18n extract/audit …
β€” wp htmlphp health (findings incl. engine diagnostics backlog)

Note

Canonical spec: docs/CLI.md.

Clone this wiki locally