Symfony LiquidBundle template engine for PHP

1.0.4 2020-10-03 18:14 UTC

This package is auto-updated.

Last update: 2021-12-31 00:16:40 UTC


Liquid is a PHP port of the Liquid template engine for Ruby, which was written by Tobias Lutke. Although there are many other templating engines for PHP, including Smarty (from which Liquid was partially inspired)

Why Liquid?

Why another templating library?

Liquid was written to meet three templating library requirements: good performance, easy to extend, and simply to use.


You can install this lib via composer:

composer require codemade-xyz/php-liquid-bundle

Example template

{% if products %}
	<ul id="products">
	{% for product in products %}
		<h2>{{ }}</h2>
		Only {{ product.price | price }}

		{{ product.description | prettyprint | paragraph }}

		{{ 'it rocks!' | paragraph }}

	{% endfor %}
{% endif %}

How to use Liquid in Symfony

1. Connect bundle in file bundle.php or kernel.php

Example add in kernel.php

public function registerBundles()
    $bundles = array(
        new \CodeMade\LiquidBundle\LiquidBundle()
    return $bundles;

2. Here is a simple example config

In config file add setting, if no values ​​are specified, then the default settings will be used.

  cache: '%kernel.cache_dir%/liquid'
  default_path: '%kernel.project_dir%/templates'
  filter: App\Kernel\LiquidTemplateFilter
  include_suffix: 'tpl'
  include_prefix: ''
    section: App\Kernel\LiquidTagSection
    'App': '%kernel.project_dir%/templates/App'

3. In config file framework.yaml

Add setting in framework.yaml

    engines: ['liquid']

4. Use the standard functions in the controller to process the template.

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class Index extends AbstractController

     * @Route("/")
    public function index()
        return $this->render('@App/home', [
            'document' => [
                'title' => 'Home page'




  • PHP 7.1+

Fork notes and contributors

This bundle create for Symfony and use
harrydeluxe library Liquid!