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 8y 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 1mo ago

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 32% 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.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

545.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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