Download the PHP package 0x15f/liquid without Composer

On this page you can find all versions of the php package 0x15f/liquid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package liquid

PHP Liquid

Liquid templates for PHP and Laravel, with compiled PHP rendering, Redis-backed template caching and bounded data loading.

Derived from Keepsuit PHP Liquid, preserving its MIT license and attribution. The Composer package is 0x15f/liquid; the PHP namespace remains Keepsuit\Liquid. It replaces, and cannot be installed alongside, keepsuit/liquid.

Requirements and compatibility

PHP 8.2+ and mbstring. Laravel integration supports Laravel 12 and 13; framework packages are optional for standalone use. Laravel 13 requires PHP 8.3+. Redis uses Laravel's configured PhpRedis or Predis client.

The reference fixtures use Shopify Ruby Liquid 5.13. This library is not Shopify's hosted theme platform: platform objects, sections and money/translation/asset filters require application integrations. Parsing is strict; the deprecated include tag is unsupported (use render). See security guidance.

Installation

Install from Packagist:

Laravel quick start

For user-authored templates, use the restricted execution APIs instead of the general view API. They retain compiled/Redis template caching while limiting PHP capabilities, source size, allocations and work.

Package discovery registers the provider automatically. Create resources/views/greeting.liquid:

Or use the facade:

Enable compiled templates with Redis as a shared parsed-template cache:

Compiled PHP stays on local disk for OPcache; Redis stores parsed templates, not executable PHP. Set LIQUID_CACHE_DRIVER=cache for Redis-only parsed-template caching. Laravel integration covers stores, invalidation, namespaces, extensions and worker lifecycle.

Performance and lazy data

Loading experiments cover field projection, bounded collection slices and batched lazy relationships. Measurements are synthetic local ARM64 experiments, not production capacity promises. Raw samples and reproduction instructions are included.

Usage

Create a new environment factory instance:

Then create a new template instance parsing a liquid template:

And finally render the template:

Streaming is stable for parsed and compiled templates:

Concatenating its chunks produces the same bytes as render() for the same data. Chunk boundaries may change. Captures and collection filters can buffer internally; output budgets are checked before a chunk is yielded. Use a fresh context for each response, and release the generator when cancelling a response so loop scopes are restored. See the streaming contract and Laravel responses.

Compiled templates

Compilation is opt-in. For production, use CompiledTemplatesCache to compile named templates on cache misses and load PHP artifacts on subsequent disk hits:

Cache misses compile named templates; subsequent hits load the compiled artifact. With keepInMemory: true (the default), compiled templates stay in memory for the cache instance once loaded; templates written on a miss are loaded by the next hit. Use remove($name) or clear() when templates change or the library is upgraded. For manual artifact management, call Environment::compile($parsedTemplate, $path) and load the result with require $path.

Loaded artifacts also support stream(). Compiled artifact classes remain loaded for the lifetime of a long-running worker.

Custom CanBeCompiled nodes should throw Keepsuit\Liquid\Compiler\UnsupportedNodeException to request runtime fallback. Any other exception aborts compilation. Generated yields must go through CompilerContext::writeYield(), not write('yield ...').

Output formatting

Float output follows Shopify Liquid 5.13: integral floats keep .0 ({{ 2 | times: 1.5 }} renders 3.0), other floats use the shortest decimal representation that round-trips, with Ruby-style scientific notation, -0.0, Infinity, -Infinity and NaN. Formatting relies on PHP's default serialize_precision (-1) and does not depend on the numeric locale. Like Shopify, plus, minus, times, divided_by, modulo and sum compute in decimal arithmetic on floats' shortest representation: {{ 0.0725 | times: 100 }} renders 7.25.

tablerow follows Shopify's HTML whitespace: a newline after the first <tr>, adjacent cells, \n between rows and after the final </tr>. Whitespace-control markers on raw delimiters trim only the surrounding text: {%- raw -%} a {%- endraw -%} renders a.

Compatibility change: float strings and tablerow HTML differ from earlier releases. Prices, string conversions and exact-output snapshots may need updating.

Date formatting

The date filter uses Ruby-style strftime directives: only % directives are formatted, other text is literal (date: 'Day %d at %H' produces Day 05 at 14). Day and month names are always English. Values that cannot be parsed as a date (including floats and booleans) are returned unchanged, without errors.

Numeric filters

Standard numeric filters use Liquid coercion: nil, booleans and non-numeric strings become zero; strings can supply a leading integer prefix ('1abc' | plus: 1 produces 2). Integer division rounds down, and modulo follows the divisor's sign, including for floats. Float division by zero produces Infinity, -Infinity or NaN; integer division by zero remains a Liquid error.

These conversions also apply with strictVariables and strictFilters enabled. Missing variables still report an error under strictVariables; strictFilters controls unknown filter names. rethrowErrors controls error propagation, and lazyParsing controls loading partials during rendering. Custom filters retain their own parameter types. Arithmetic uses PHP's native integer and float precision.

String and HTML filters

Standard string and HTML filters use the shared Liquid string coercion: booleans become true/false and nil becomes an empty string. Supplied string arguments use the same conversion. Optional arguments follow the filter's defaults (replace and replace_first default to an empty replacement); required arguments remain required. Integer arguments use Liquid integer validation.

split with ' ' splits whitespace runs, with '' splits multibyte characters, and otherwise drops trailing empty fields. slice accepts an offset of -size. truncatewords ignores leading whitespace when counting words and preserves the original input when no truncation is needed.

escape, its alias h, and escape_once encode only & < > " ', using &#39; for apostrophes. strip_html removes multiline script/style blocks and comments. URL-safe Base64 filters are available; encoding includes padding, while decoding accepts omitted padding and rejects malformed encodings. Standard Base64 decoding requires correctly padded input.

These conversions also apply with strict options enabled. Missing variables still report errors under strictVariables, unknown filters follow strictFilters, and rethrowErrors controls propagation. lazyParsing only controls partial loading. Custom filters retain their own parameter types. The shared string coercion supports scalars and Stringable objects; arrays and other objects become empty strings rather than Ruby-style representations.

Array filters

Standard array filters accept nil, scalars, lists, hashes, and iterators. Filters using a collection flatten nested PHP lists, preserve associative arrays as hashes, and bind drops to the current context. An empty PHP array is a list, so nested empty arrays disappear during flattening. Iterator entries retain their structure. first, last, and size preserve the original collection shape; first on a hash returns its first key/value pair, while last returns nil. Hash lookups retain their existing key-based behavior; use the explicit first filter for a pair. On integers, size returns the native integer byte size, as in Ruby.

map retains arrays returned by properties; a subsequent join flattens them. concat flattens its input but keeps the appended array's structure and requires an array argument. join uses Liquid string conversion, including boolean names, float types, and Ruby-style hash representations. sum uses the shared numeric coercion, including leading numeric prefixes.

uniq preserves the first occurrence and distinguishes integers, floats, strings, and booleans. Hashes compare by content regardless of key order, and drops compare by identity unless they expose a Liquid value. compact removes only nil. Without a target, where, reject, has, find, and find_index treat only nil and false as falsy; with a target they use condition equality. sort rejects incompatible types with a Liquid argument error; sort_natural compares strings case-insensitively.

These rules apply with strict options enabled. Missing variables still follow strictVariables, unknown filters follow strictFilters, and rendering errors follow the configured handler or rethrowErrors. lazyParsing only controls partial loading, and parsing remains strict. Custom filters retain their parameter types.

Drops

Liquid support almost any kind of object but in order to have a better control over the accessible data in the templates, you can pass your data as Drop objects and have a better control over the accessible data. Drops are standard php objects that extend the Keepsuit\Liquid\Drop class. Public properties and public methods of the class will be accessible in the template as a property. You can also override the liquidMethodMissing method to handle undefined properties.

Liquid provides some attributes to control the behavior of the drops:

If you implement the MapsToLiquid interface in your domain classes, the liquid renderer will automatically convert your objects to drops.

Advanced usage

Custom tags

To create a custom tag, you need to create a class that extends the Keepsuit\Liquid\Tag abstract class (or Keepsuit\Liquid\TagBlock if tag has a body).

[!NOTE] Take a look at the implementation of default tags to see how to implement parse and render methods.

Then you need to register the tag in the environment:

Custom filters

To create a custom filter, you need to create a class that extends the Keepsuit\Liquid\Filters\FiltersProvider abstract class.

Each public method of the class will be registered as a filter. You can "hide" a public method with the Hidden attribute, so it will not be registered as filter.

Then you need to register the filters provider in the environment:

Extensions

Extensions allow you to add custom tags, filters, and other features to the liquid environment.

To create a custom extension, you need to create a class that extends the Keepsuit\Liquid\Extensions\Extension abstract class.

Then you need to register the extension in the environment:

Templates cache

By default parsed templates are kept in a MemoryTemplatesCache, which lasts as long as the PHP process, so with PHP-FPM every request parses the templates again. SerializeTemplatesCache and VarExportTemplatesCache store parsed templates on disk; CompiledTemplatesCache stores executable PHP artifacts. With keepInMemory: true (the default) each template is read from disk only once per cache instance.

VarExportTemplatesCache requires symfony/var-exporter.

Resource limits

Keepsuit\Liquid\Render\ResourceLimits supports both per-render limits and cumulative resource limits.

Per-render counters can be reset between renders. Cumulative counters are intended for a full render lifecycle so repeated partial renders can share the same budget.

Configure bounded limits on the environment before parsing/compiling. Compiled artifacts declare whether they contain allocation guards; unrestricted artifacts reject bounded contexts. Guarded artifacts accept different limits in fresh request contexts. For user-authored templates, EnvironmentFactory::forUntrustedTemplates() selects the guarded profile and PHP capability policy together; see security guidance.

Custom tags and filters

By default, only the standard liquid tags and filters are available. But this package provides some custom tags and filters that you can use.

Tags

Filters

Testing and contributing

See CONTRIBUTING.md for Docker-based development, Redis integration tests, static analysis and formatting checks.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of liquid with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-mbstring Version *
brick/math Version ^0.14.3 || ^0.15 || ^0.16 || ^0.17 || ^0.18 || ^0.19 || ^0.20 || ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package 0x15f/liquid contains the following files

Loading the files please wait ...