zentlix / twig-extensions
Additional Twig extensions for Spiral Framework.
Requires
- php: ^8.1
- spiral/boot: ^3.7
- spiral/router: ^3.7
- spiral/twig-bridge: ^2.0.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- phpunit/phpunit: ^10.1
- spiral/nyholm-bridge: ^v1.3
- spiral/testing: ^2.3
- spiral/translator: ^3.7
- vimeo/psalm: ^5.10
This package is auto-updated.
Last update: 2024-11-11 03:01:05 UTC
README
Requirements
Make sure that your server is configured with following PHP version and extensions:
- PHP 8.1+
- Spiral framework 3.7+
Installation
You can install the package via composer:
composer require zentlix/twig-extensions
To enable the package in your Spiral Framework application, you will need to add
the Zentlix\TwigExtensions\Bootloader\ExtensionsBootloader
class to the list of bootloaders in your application:
protected const LOAD = [ // ... \Zentlix\TwigExtensions\Bootloader\ExtensionsBootloader::class, ];
Note If you are using
spiral-packages/discoverer
, you don't need to register bootloader by yourself.
Available functions
path
Generate valid route URL using route name and set of parameters.
{{ path('user.edit', {'id': 1}) }}
Available filters
trans
Translates the given message.
{{ 'message' | trans }}
Available tests
of_type
Checks that the value is of the correct type. Available checks: array
, bool
, object
, class
, float
, int
,
numeric
, scalar
, string
.
{% if someVar is of_type('string') %} // ... {% else %} // ... {% endif %}
Testing
composer test
composer psalm
composer cs
License
The MIT License (MIT). Please see License File for more information.