PHPackages                             codemade-xyz/php-liquid-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. codemade-xyz/php-liquid-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

codemade-xyz/php-liquid-bundle
==============================

Symfony LiquidBundle template engine for PHP

1.0.4(5y ago)121MITPHPPHP &gt;= 7.1CI failing

Since Sep 7Pushed 5y agoCompare

[ Source](https://github.com/codemade-xyz/php-liquid-bundle)[ Packagist](https://packagist.org/packages/codemade-xyz/php-liquid-bundle)[ Docs](https://github.com/codemade-xyz/php-liquid-bundle)[ RSS](/packages/codemade-xyz-php-liquid-bundle/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (5)Dependencies (7)Versions (6)Used By (0)

Symfony 5.1 Liquid Bundle - template engine for PHP
===================================================

[](#symfony-51-liquid-bundle---template-engine-for-php)

Liquid is a PHP port of the [Liquid template engine for Ruby](https://github.com/Shopify/liquid), 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-liquid)

Why another templating library?

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

Installing
----------

[](#installing)

You can install this lib via [composer](https://getcomposer.org/):

```
composer require codemade-xyz/php-liquid-bundle

```

Example template
----------------

[](#example-template)

```
{% if products %}

	{% for product in products %}

		{{ product.name }}
		Only {{ product.price | price }}

		{{ product.description | prettyprint | paragraph }}

		{{ 'it rocks!' | paragraph }}

	{% endfor %}

{% endif %}

```

How to use Liquid in Symfony
----------------------------

[](#how-to-use-liquid-in-symfony)

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

[](#1-connect-bundle-in-file-bundlephp-or-kernelphp)

Example add in kernel.php

```
public function registerBundles()
{
    $bundles = array(
        ...
        new \CodeMade\LiquidBundle\LiquidBundle()
    );

    return $bundles;
}

```

#### 2. Here is a simple example config

[](#2-here-is-a-simple-example-config)

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

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

```

#### 3. In config file framework.yaml

[](#3-in-config-file-frameworkyaml)

Add setting in framework.yaml

```
framework:
  ...
  templating:
    engines: ['liquid']

```

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

[](#4-use-the-standard-functions-in-the-controller-to-process-the-template)

```
