PHPackages                             larakit/lk-twig - 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. larakit/lk-twig

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

larakit/lk-twig
===============

\[Larakit\] Шаблонизатор Twig

01.4kPHP

Since Apr 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/larakit/lk-twig)[ Packagist](https://packagist.org/packages/larakit/lk-twig)[ RSS](/packages/larakit-lk-twig/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

[![Total Downloads](https://camo.githubusercontent.com/ca085c798c2b44b916e4904130c2e61bceb925dc398b7e71e982c335c0fabb2a/68747470733a2f2f706f7365722e707567782e6f72672f6c6172616b69742f6c6b2d747769672f642f746f74616c2e737667)](https://packagist.org/packages/larakit/lk-twig)[![Latest Stable Version](https://camo.githubusercontent.com/33004383be5d758504b188997e30ba9019d106abce2d71d3d06a5b3a9f06d9fe/68747470733a2f2f706f7365722e707567782e6f72672f6c6172616b69742f6c6b2d747769672f762f737461626c652e737667)](https://packagist.org/packages/larakit/lk-twig)[![Latest Unstable Version](https://camo.githubusercontent.com/e6b419bf4fb74556056eb94045f8f8bfc084b4cd05e546e0f3fee022f55e6536/68747470733a2f2f706f7365722e707567782e6f72672f6c6172616b69742f6c6b2d747769672f762f756e737461626c652e737667)](https://packagist.org/packages/larakit/lk-twig)[![License](https://camo.githubusercontent.com/c7e6363586cb26561a9ce4fdeebc2359ed5e2760e9779335de73161e7c8460dc/68747470733a2f2f706f7365722e707567782e6f72672f6c6172616b69742f6c6b2d747769672f6c6963656e73652e737667)](https://packagist.org/packages/larakit/lk-twig)

larakit-twig
============

[](#larakit-twig)

Модуль Twig для Larakit

\#Возможности ##Step 1 Создавая пакет указываем в composer.json автоподключаемый файл init.php

```
{
    "name": ".../...",
    "description": "...",
    "license": "MIT",
    "require": {
        ...
    },

    "autoload": {
        "files": [
			"src/init.php"
        ]
    }
}

```

\##Step 2 В файле "src/init.php" регистрируем функции, фильтры и расширения

### Добавление фильтров

[](#добавление-фильтров)

```
Larakit\Twig::register_filter('int', 'intval');
Larakit\Twig::register_filter('filter_prefix', function($val){
   return 'prefix_'.$value;
});
```

Использование в шаблонах Twig

```
{% set var = '123a' %}
Приводим к целому: {{ var|int }}
Добавляем префикс: {{ var|filter_prefix('pref') }}
```

Результат:

```
Приводим к целому: 123
Добавляем префикс: pref_123
```

### Добавление функций

[](#добавление-функций)

```
Larakit\Twig::register_function('lower', 'mb_strtolower');
Larakit\Twig::register_function('function_prefix', function($val, $prefix='prefix'){
   return $prefix.'_'.$value;
});
```

Использование в шаблонах Twig

```
{% set var = 'AbCdEfG' %}
В нижнем регистре: {{ lower(var) }}
Добавляем префикс: {{ function_prefix(var, 'PRE') }}
```

Результат:

```
В нижнем регистре: abcdefg
Добавляем префикс: PRE_AbCdEfG
```

### Добавление тестов

[](#добавление-тестов)

```
Larakit\Twig::register_test('num', 'is_numeric');
Larakit\Twig::register_test('age_alcohol', function($val){
   return intval($val)>=18;
});
```

Использование в шаблонах Twig

```
{% set var = 38 %}
Значение {{ var }} является числом: {% if var is num %}YES{% else %}NO{% endif%}
Можно ли пить в {{ var }} лет: {% if var is age_alcohol %}YES{% else %}NO{% endif%}
```

Результат:

```
Значение 38 является числом: YES
Можно ли пить в 38 лет: YES
```

###  Health Score

24

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.2% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6363b0982fef3f509f7ec819366c669e81cfc87090306743ca9ecd99425139b0?d=identicon)[larakit](/maintainers/larakit)

---

Top Contributors

[![aberdnikov](https://avatars.githubusercontent.com/u/478597?v=4)](https://github.com/aberdnikov "aberdnikov (16 commits)")[![Sharoff45](https://avatars.githubusercontent.com/u/7892544?v=4)](https://github.com/Sharoff45 "Sharoff45 (3 commits)")

### Embed Badge

![Health badge](/badges/larakit-lk-twig/health.svg)

```
[![Health](https://phpackages.com/badges/larakit-lk-twig/health.svg)](https://phpackages.com/packages/larakit-lk-twig)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k43.7M268](/packages/mustache-mustache)[knplabs/knp-paginator-bundle

Paginator bundle for Symfony to automate pagination and simplify sorting and other features

1.8k42.2M286](/packages/knplabs-knp-paginator-bundle)[symfony/templating

Provides all the tools needed to build any kind of template system

1.0k68.7M530](/packages/symfony-templating)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8122.9M24](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7052.9M32](/packages/mopa-bootstrap-bundle)[vincentlanglet/twig-cs-fixer

A tool to automatically fix Twig code style

3297.7M54](/packages/vincentlanglet-twig-cs-fixer)

PHPackages © 2026

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