PHPackages                             crecket/custom-twig-extension - 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. crecket/custom-twig-extension

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

crecket/custom-twig-extension
=============================

My custom twig extension

2.2(10y ago)01442WTFPLPHP

Since Oct 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Crecket/custom-twig-extension)[ Packagist](https://packagist.org/packages/crecket/custom-twig-extension)[ Docs](https://github.com/Crecket/custom-twig-extension)[ RSS](/packages/crecket-custom-twig-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (17)Used By (0)

custom-twig-extension
=====================

[](#custom-twig-extension)

[![GitHub release](https://camo.githubusercontent.com/7fdaa6bf97c88187850dfc2e2d4cdd951a3017fbc5e2844a137b737b5cfaadc4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f637265636b65742f637573746f6d2d747769672d657874656e73696f6e2e737667)](https://github.com/Crecket/custom-twig-extension)[![Packagist](https://camo.githubusercontent.com/39811fa80544c9b673a0e69e457bf24ffc4f3dc874ca1fa69c14d6bace920bea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f637265636b65742f637573746f6d2d747769672d657874656e73696f6e2e737667)](https://packagist.org/packages/crecket/custom-twig-extension)

Content
-------

[](#content)

1. Introduction
2. Requirements
3. Installation
4. Usage
5. License

Introduction
------------

[](#introduction)

This repo contains my custom twig extension. In here you'll find a few native php functions added to twig as a twig extension. Things like creating a random number or using json\_decode can now be done directly in Twig.

Requirements
------------

[](#requirements)

- Twig ^1.25

Installation
------------

[](#installation)

#### Composer

[](#composer)

1. Require the repo with composer `composer require crecket/custom-twig-extension`
2. Add the extension to the twig view (custom\_twig\_extension is the class)

```
$twig = new Twig_Environment();
$twig->addExtension(new custom_twig_extension());

```

#### Manual

[](#manual)

1. Download the source
2. Require the file
3. Add the extension to the twig view

Usage
-----

[](#usage)

Using these functions and filters is the same as the native functions and filters.

Quick example:

- print\_r()

```
{{ print_r(array) }}

```

- json\_decode

```
{{ some_variable|json_decode }}

```

List
----

[](#list)

#### Functions

[](#functions)

1. dumpPre(var1, var2, var3 ...)
2. md5(password)
3. password\_hash(password)
4. phpinfo()
5. print\_r(array)
6. pseudoBytes(length)
7. randomHex(length)
8. randomInt(length)
9. randomString(length)
10. unsetSession(key)
11. wordwrap(string, length, limiter = "\\n", cut)

#### Filters

[](#filters)

1. json\_decode
2. urlDecode

### Globals

[](#globals)

1. sessionVars //Returns all php SESSION variables in array form

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 97.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~24 days

Total

15

Last Release

3677d ago

Major Versions

1.8.1 → 2.02016-01-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce40a957cded3417a986fc49971e429eafbf3ead0a2c8e23433b61fa360b22e8?d=identicon)[Crecket](/maintainers/Crecket)

---

Top Contributors

[![Crecket](https://avatars.githubusercontent.com/u/7481136?v=4)](https://github.com/Crecket "Crecket (44 commits)")[![Langmans](https://avatars.githubusercontent.com/u/756540?v=4)](https://github.com/Langmans "Langmans (1 commits)")

### Embed Badge

![Health badge](/badges/crecket-custom-twig-extension/health.svg)

```
[![Health](https://phpackages.com/badges/crecket-custom-twig-extension/health.svg)](https://phpackages.com/packages/crecket-custom-twig-extension)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91292.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36663.2M221](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

21946.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21814.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
