PHPackages                             gupalo/twigext - 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. gupalo/twigext

ActiveLibrary[Templating &amp; Views](/categories/templating)

gupalo/twigext
==============

Twig Extensions

1.9.0(4mo ago)019.6k↓17.6%MITPHPPHP &gt;=8.4

Since Jan 4Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/gupalo/twigext)[ Packagist](https://packagist.org/packages/gupalo/twigext)[ RSS](/packages/gupalo-twigext/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (21)Used By (0)

Twig Ext
========

[](#twig-ext)

Twig Extensions

Usage
-----

[](#usage)

```
composer require gupalo/twigext

```

Symfony
-------

[](#symfony)

Add to `config/services.yaml`

```
Gupalo\TwigExt\:
    resource: '../vendor/gupalo/twigext/src/TwigExt'
    tags: ['twig.extension']

```

You can customize FormatExtension:

```
Gupalo\TwigExt\FormatExtension:
    bind:
        $translations:
            span: div
            format-date-zero: text-warning
        $wrapSpan: false

```

ArrayExtension
--------------

[](#arrayextension)

### uniq(items, keepKeys = false)

[](#uniqitems-keepkeys--false)

`array_unique`

If `keepKeys = false` (default) then `array_values` of the result.

### max\_value(items, field)

[](#max_valueitems-field)

Max of `field` values of `items`.

Uses `PropertyAccessor` so it may be object with properties

### max\_ratio\_value(items, field, field2)

[](#max_ratio_valueitems-field-field2)

Max of `field/field2` values of `items`.

Uses `PropertyAccessor` so it may be object with properties

### sum\_value(items, field)

[](#sum_valueitems-field)

Sum of field values.

Uses `PropertyAccessor` so it may be object with properties

### array\_sum(items)

[](#array_sumitems)

EncodingExtension
-----------------

[](#encodingextension)

### base64\_encode

[](#base64_encode)

### base64\_decode

[](#base64_decode)

### md5

[](#md5)

ExitExtension
-------------

[](#exitextension)

### exit

[](#exit)

Throw `TwigExitException`. You app should intercept and process it.

FormatExtension
---------------

[](#formatextension)

### int

[](#int)

### float

[](#float)

### money

[](#money)

### percents

[](#percents)

### date\_full

[](#date_full)

### date\_short

[](#date_short)

### date\_noyear

[](#date_noyear)

JsonExtension
-------------

[](#jsonextension)

### json\_decode

[](#json_decode)

`json_decode` array.

If there will be invalid string then there will be no error, just an empty array.

ProgressExtension
-----------------

[](#progressextension)

### progress\_class

[](#progress_class)

### progress\_percents

[](#progress_percents)

### progress\_int

[](#progress_int)

### progress\_float

[](#progress_float)

RandomExtension
---------------

[](#randomextension)

### random\_hour, random\_day

[](#random_hour-random_day)

Pseudorandom. Default `1..100`.

```
{% if random_day()  40 %}otherwise, you'll see this text{% endif %}

{% if random_day()
