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
Laravel Twigbridge

Laravel Twigbridge Laravel Package

barryvdh/laravel-twigbridge

TwigBridge lets you use the Twig templating engine in Laravel alongside Blade. It provides Twig extensions for Laravel helpers, facades, and auth, plus view integration so you can render .twig templates with familiar syntax and caching support.

View on GitHub
Deep Wiki
Context7

Twig view integration for Laravel 4

Frequently asked questions about Laravel Twigbridge
What is barryvdh/laravel-twigbridge used for?
It lets Laravel 4 applications render .twig templates through Laravel's normal view system, so Twig can be used alongside Blade. It also registers Twig extensions that expose Laravel helpers, facades, auth checks, and shared view data inside templates. In practice it is a rendering adapter for legacy Laravel 4 apps that already have a Twig template estate.
How do I install and set up laravel-twigbridge?
Require the package with Composer, then register Barryvdh\TwigBridge\TwigServiceProvider in app/config/app.php. Publish the config file so you can set twig.paths, twig.options, and the extensions, functions, and filters maps. After that, render through the normal View::make path and controllers do not need changes. Before writing custom extensions, confirm which Twig version is resolved in composer.lock.
Does laravel-twigbridge support Laravel 5, 6, 8, or 10?
No, this package targets Laravel 4 only. For Laravel 5 and later the maintained equivalent is rcrowe/twigbridge. For modern Laravel the defensible choice is native Blade, or an API plus SPA or Inertia if the team wants a component-driven frontend. Twig on Laravel should not be presented as a route to a modern stack.
Which Twig version does barryvdh/laravel-twigbridge require?
The package targets Twig 1.x, so check composer show twig/twig against your actual lockfile before building anything on top of it. Twig 2 and 3 renamed Twig_Extension to AbstractExtension and changed several signatures, which breaks custom extensions written for this bridge. Any claim of PHP 8 or modern Twig compatibility should be treated as unproven until a time-boxed spike confirms it.
How do I use Laravel helpers like route(), asset(), or csrf_token() in Twig templates?
TwigBridge registers Twig extensions that expose Laravel helpers, facades, auth, and shared data as Twig functions. You can also register your own functions and filters through the package config. Because autoescaping is on by default, helper output that contains HTML, such as a rendered CSRF field, needs deliberate use of the raw filter on trusted data only.
How do I configure Twig paths, cache, debug, and auto_reload options?
Publish the package config to get twig.paths and twig.options, where cache, debug, and auto_reload are set. Compiled templates are written under app/storage/views. Stale compiled templates are the routine failure mode in this setup, so clearing that cache is the first thing to rule out when template changes do not appear.
Is TwigBridge safe with autoescaping, and how should I handle CSRF or auth output?
Autoescaping is enabled by default, which protects against XSS as long as you do not blanket-apply raw to helper output. HTML-bearing helpers such as a rendered CSRF field are the classic case where raw is needed, and it should be limited to trusted data. Missing Blade directives like csrf, auth, can, and error mean authorization checks must be rebuilt as Twig functions or controller-passed booleans, and a silent regression there is a security incident rather than a cosmetic bug.
How do I test Twig templates in a Laravel 4 app using TwigBridge?
Rendering still goes through Laravel's normal View::make path, so existing view and HTTP tests keep working and can assert against the rendered content. You can also render templates directly in isolation for faster unit-style checks. Clear the compiled template cache between test runs if you change templates mid-suite.
Is barryvdh/laravel-twigbridge still maintained, and should I use it in a new project?
The repository is archived with roughly 56 stars and zero dependents, so there is no upstream to file issues against. Your team assumes full ownership of patching and security review from day one. It has no role in new Laravel work; use Blade or rcrowe/twigbridge for Laravel 5 and later. Treat any use as containment for a legacy system, not as a foundation.
What are the alternatives to laravel-twigbridge?
For Laravel 5 and later, rcrowe/twigbridge is the maintained Twig integration. For modern Laravel, native Blade is the default answer, or an API with SPA or Inertia if you want a component-driven frontend. Migrating off TwigBridge is a project rather than a simple upgrade, because it also means replacing Twig templates, custom extensions, macros, and config-registered closures.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console