Search by

A JSX-style template engine for PHP with compiled rendering, components, schema validation, and restricted JavaScript-style expressions.

v0.1.0 2026-09-12 16:03 UTC

This package is auto-updated.

Last update: 2026-09-12 16:04:30 UTC


README

A JSX-style template engine for PHP with compiled rendering, reusable components, schema validation, and restricted JavaScript-style expressions.

Liqx combines HTML markup and {expression} interpolation with Liquid-inspired sections, snippets, filters, and schemas. It supports both interpreted rendering and compilation to cached PHP closures.

Requirements

PHP 8.2 or newer with mbstring, and Composer 2.

Installation

Install the stable release from Packagist:

composer require phpmystic/liqx:^0.1

Quick start

<?php
require 'vendor/autoload.php';

use Phpmystic\Liqx\Template;

$template = Template::parse('<h1>Hello, {name | escape}!</h1>');
echo $template->render(['name' => 'World']);
// <h1>Hello, World!</h1>

Parse once and render with different data. Use the escape filter for untrusted values inserted into HTML text; interpolation does not automatically HTML-escape output.

Features

  • HTML-style templates with expressions, filter pipes, conditional markup, and array mapping.
  • Frontmatter declarations, destructuring, functions, and conditional statements.
  • Reusable snippets, named templates, sections, and slots.
  • Schema validation for template props.
  • Custom filters and global functions through Environment.
  • Optional compilation to native PHP with a disk cache.
use Phpmystic\Liqx\Environment;
use Phpmystic\Liqx\Template;

$environment = Environment::create();
$environment->setCompiledTemplateDir(__DIR__ . '/var/cache/liqx');
$template = Template::parse('<p>{message | escape}</p>', $environment);
echo $template->render(['message' => 'Compiled with Liqx']);

The compiled cache directory must be writable by the application. Registered PHP filters and globals are host-provided capabilities; the expression language is a restricted subset, not a general JavaScript runtime.

Documentation

Read the syntax reference for document structure, expressions, frontmatter, filters, components, and schemas. Its examples are exercised by the test suite.

Editor integrations are available in the repository for VS Code and PhpStorm.

Development

git clone https://github.com/mehdilight/liqx.git
cd liqx
composer install
composer validate --strict
composer lint
composer test
composer analyse

CI runs syntax checks, tests, and static analysis on PHP 8.2–8.5. Include a minimal reproduction with bug reports and regression tests with fixes. Changes to the renderer should preserve interpreted and compiled behavior.

Releases

Versions are derived from Git tags; composer.json deliberately omits a version field, following Packagist's versioning guidance.

To publish a release, confirm CI passes on main, then create and push a semantic version tag. Packagist indexes the tag as a package version. The GitHub integration keeps releases synchronized; maintainers can also trigger an update from the package page.

License

Liqx is licensed under the MIT License.