Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Twig Extensions

Twig Extensions Laravel Package

jasny/twig-extensions

Jasny Twig Extensions adds practical filters and functions to Twig for common template tasks, including array manipulation, date/time formatting, and string helpers like truncation and slugs. A lightweight way to reduce custom Twig code in PHP apps.

Deep Wiki
Context7

A number of useful filters for Twig

Frequently asked questions about Twig Extensions
Is jasny/twig-extensions compatible with Laravel?
It is not a Laravel package, so there is no service provider, facade, config file, or Blade integration. It only fits a Laravel application that already renders templates through Twig, usually via TwigBridge. In a standard Blade app, installing it would mean adding Twig just to use a few filters, which is a poor architectural trade.
How do I install jasny/twig-extensions in a Laravel app?
Install it with Composer, then register the extension with the Twig environment used by your app. If you use TwigBridge, that is typically done through TwigBridge configuration or a service provider. There are no migrations, queues, storage services, or other runtime setup steps.
Does jasny/twig-extensions work with Blade templates?
No. The package provides Twig filters and functions, not Blade directives or a Blade compiler extension. It cannot be consumed directly from .blade.php templates. You would need an existing Twig rendering path to use it.
How do I register Jasny Twig Extensions with TwigBridge?
Register it as a Twig extension in the Twig environment configured by TwigBridge, often through the package's extension configuration or a small service provider. Then verify that the specific filters are available and escaped correctly in representative templates. Exact config keys depend on your Laravel and TwigBridge versions, so test the registration in a branch first.
What filters does jasny/twig-extensions provide?
The package describes practical Twig filters for common template tasks, including array manipulation, date and time formatting, and string helpers such as truncation and slugs. It is intended to reduce custom Twig code for these routine operations. Check the actual filter list and behavior against your required use cases before adopting it.
Does jasny/twig-extensions support PHP 8 and Twig 3?
The last release is from 2020-10-08, so PHP 8.x and Twig 3.x compatibility should be verified rather than assumed. Pin the package version and test it with your exact PHP, Twig, TwigBridge, and Laravel versions. If constraint conflicts or runtime deprecations appear, prefer a small internal extension or a controlled fork over patching vendor code ad hoc.
Is jasny/twig-extensions still maintained?
Maintenance signals are limited: the last release was in October 2020, the project has modest stars, and the repository is listed as unknown in this evaluation. It may still work, but you should assume limited ongoing maintenance and verify provenance and tests. Treat it as a pinned, isolated utility dependency with an exit plan, not a platform-level dependency.
How should I handle escaping with Jasny Twig filters?
Escaping and raw HTML behavior matter most for filters that process user-visible content, especially date/time, slug, truncation, and markup-related filters. Verify how each filter's output is escaped in your Twig environment and which filters can emit raw HTML. Add application-level rendering tests for the templates that use them.
Should I use jasny/twig-extensions or write my own Twig extension?
If you only need one or two filters, an internal Twig extension is often the better product decision than adding an aging third-party dependency. Writing your own extension keeps behavior, escaping, and maintenance under your control. Use jasny/twig-extensions when you already have Twig and need several filters where the dependency cost is justified.
What are alternatives to jasny/twig-extensions for Laravel?
For a Blade-first Laravel app, the main alternative is to keep using Blade and implement the needed helpers as Blade directives, components, or PHP helpers. For an existing Twig stack, alternatives include writing a small internal Twig extension, using TwigBridge's built-in extensions, or selecting a more actively maintained Twig extension package. The right choice depends on whether Twig is already part of your architecture.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo