keepsuit/laravel-liquid

Liquid template engine for Laravel
64,054 9
Install
composer require keepsuit/laravel-liquid
Latest Version:v0.6.3
PHP:^8.2
Laravel:11 · 12 · 13
Older releases:10
License:MIT
Last Updated:Oct 20, 2026
Links: GitHub  ·  Packagist
Maintainer: cappuc

Liquid template engine for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a Laravel view integration of the Shopify Liquid template engine. It uses keepsuit/liquid PHP porting under the hood to parse liquid templates.

Installation

You can install the package via composer:

composer require keepsuit/laravel-liquid

Usage

  1. Create a liquid template file in resources/views folder (for example home.liquid).
  2. Render the template as usual with Laravel view engine.
class HomeController extends Controller
{
    public function index()
    {
        return view('home');
    }
}

PHP compilation

Views and partials are compiled to PHP using Liquid 0.13's compiler. Artifacts use Laravel's configured view.compiled directory and respect view.cache. Laravel tags, filters, and parse-time outputs remain available. Views and the Liquid facade share loaded compiled templates within a request.

To send a template as it renders, without building the whole output in memory:

return response()->stream(function () {
    foreach (Liquid::stream('home', ['name' => 'World']) as $chunk) {
        echo $chunk;
    }
});

To compile all Liquid views ahead of time (e.g. on deploy) run php artisan liquid:cache. It also runs as part of php artisan optimize. view:cache only handles Blade views, and view:clear / optimize:clear remove the Liquid artifacts as well.

Tags

This package provides some custom tags in addition to the standard Liquid tags.

Auth

Check if the user is authenticated. Same as laravel @auth directive.

{% auth %}
user is authenticated
{% endauth %}

{% guest %}
user is not authenticated
{% endguest %}

or with custom guard

{% auth('admin') %}
admin is authenticated
{% endauth %}

{% guest 'admin' %}
admin is not authenticated
{% endguest %}

Env

Check if the application environment is the specified one. Same as laravel @env directive.

{% env 'production' %}
application is in production environment
{% endenv %}

Session

Check if the session has a specific key. Same as laravel @session directive. The value of the session key can be accessed with the value variable.

{% session 'status' %}
<div class="p-4 bg-green-100">
  {{ value }}
</div>
{% endsession %}

Error

Check if a validation error exists for the given field. Same as laravel @error directive. The error message can be accessed with the message variable.

{% error 'email' %}
<div class="text-red-500 text-sm">
  {{ message }}
</div>
{% enderror %}

Csrf field

Generate a hidden CSRF token form field. Same as laravel @csrf directive.

<form method="POST" action="/foo">
  {% csrf %}
  ...
</form>

Vite

Adds your vite assets to the template. Same as laravel @vite directive.

{% vite 'resources/css/app.css', 'resources/js/app.js' %}

{% comment %}With custom build directory{% endcomment %}
{% vite "resources/js/app.js", directory: "custom" %}

Filters

This package provides some custom filters in addition to the standard Liquid filters.

Debug

Debug variable content with dump and dd filters.

{{ variable | dump }}

{{ variable | dd }}

Localization

Translate a string with trans (or t alias) and trans_choice filters using the Laravel localization system.

{{ 'messages.welcome' | trans }}

{{ 'messages.items_count' | trans_choice: 3 }}

Url

Generate urls using the laravel url helpers.

{{ 'app.js' | asset }}
{{ 'app.js' | secure_asset }}

{{ '/home' | url }}
{{ '/home' | secure_url }}

{{ 'home' | route }}

Testing

Run the suite with compiled templates:

composer test

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.

Related Packages

simexis/laravel-liquid

Liquid template engine for Laravel

1,510 18
keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

1,059,723 190
keepsuit/laravel-zoho-campaigns

Manage Zoho Campaigns from Laravel

12,612 2
keepsuit/laravel-cookie-solution

Make your site comply with EU cookie law

10,337 4

Version History

Version Released PHP Laravel License
v0.6.3 ^8.2 ^11.0 || ^12.0 || ^13.0 MIT
v0.6.2 ^8.2 ^11.0 || ^12.0 || ^13.0 MIT
v0.6.1 ^8.2 ^11.0 || ^12.0 || ^13.0 MIT
v0.6.0 ^8.2 ^11.0 || ^12.0 || ^13.0 MIT
v0.5.5 ^8.1 ^10.0 || ^11.0 || ^12.0 MIT
Pre-releases (4)
Version Released PHP Laravel License
v0.7.0-beta.1 ^8.2 ^11.28 || ^12.0 || ^13.0 MIT
v0.5.0-beta3 ^8.1 ^10.0 || ^11.0 MIT
v0.5.0-beta2 ^8.1 ^10.0 || ^11.0 MIT
v0.5.0-beta1 ^8.1 ^10.0 || ^11.0 MIT