PHPackages                             gencer/twigbridge-laravel-4 - 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. gencer/twigbridge-laravel-4

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

gencer/twigbridge-laravel-4
===========================

Adds the power of Twig to Laravel

v0.6.1(11y ago)030MITPHPPHP &gt;=5.4.0

Since Nov 27Pushed 11y ago1 watchersCompare

[ Source](https://github.com/gencer/TwigBridge-Laravel-4)[ Packagist](https://packagist.org/packages/gencer/twigbridge-laravel-4)[ RSS](/packages/gencer-twigbridge-laravel-4/feed)WikiDiscussions Branch\_0.6.0-beta3 Synced yesterday

READMEChangelogDependencies (7)Versions (42)Used By (0)

Allows you to use [Twig](http://twig.sensiolabs.org/) seamlessly in [Laravel 4](http://laravel.com/).

[![Latest Stable Version](https://camo.githubusercontent.com/56cf51cbd14b77bd5e0981f0c2baf5bb1de539278459335460dee1f182befb44/68747470733a2f2f706f7365722e707567782e6f72672f7263726f77652f747769676272696467652f762f737461626c652e706e67)](https://packagist.org/packages/rcrowe/twigbridge)[![Total Downloads](https://camo.githubusercontent.com/6c882ef7719132c55bc59444a61ad7549e15be6ad9151532be8ec64f26d21057/68747470733a2f2f706f7365722e707567782e6f72672f7263726f77652f747769676272696467652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/rcrowe/twigbridge)[![Build Status](https://camo.githubusercontent.com/2a065e32d3ba8730adbcbd1df4ad7f9382ce01daf754100fe6c9bbd3c5b94b7b/68747470733a2f2f7472617669732d63692e6f72672f7263726f77652f547769674272696467652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/rcrowe/TwigBridge)[![Coverage Status](https://camo.githubusercontent.com/d35020c9c35fa79a001f2896dccafc36a1870db5e743af4ba734de6f4b24df96/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f7263726f77652f547769674272696467652f62616467652e706e673f6272616e63683d302e36)](https://coveralls.io/r/rcrowe/TwigBridge?branch=0.6)[![License](https://camo.githubusercontent.com/01a5496be25791c602b64cfc8c4e386b984484df2644bdae115ce15df30867ed/68747470733a2f2f706f7365722e707567782e6f72672f7263726f77652f747769676272696467652f6c6963656e73652e706e67)](https://packagist.org/packages/rcrowe/twigbridge)

**NOTE**: This is a fork of current TwigBridge by Robert Crowe. I maintained this because the current beta stage forces us to use dev branch of all repos. I do not want to use dev branch for all components, personally :)

Installation
============

[](#installation)

Add `gencer/twigbridge-laravel-4` as a requirement to composer.json:

```
{
    "require": {
        "gencer/twigbridge-laravel-4": "0.6.*"
    }
}
```

Update your packages with `composer update` or install with `composer install`.

Once Composer has installed or updated your packages you need to register TwigBridge with Laravel itself. Open up app/config/app.php and find the providers key towards the bottom and add:

```
'TwigBridge\ServiceProvider'
```

You can add the TwigBridge Facade, to have easier access to the TwigBridge (or Twig\_Environment).

```
'Twig' => 'TwigBridge\Facade\Twig',
```

```
Twig::addExtension('TwigBridge\Extension\Loader\Functions');
Twig::render('mytemplate', $data);
```

Configuration
=============

[](#configuration)

TwigBridge's configuration file can be extended by creating `app/config/packages/rcrowe/twigbridge/config.php`. You can find the default configuration file at vendor/rcrowe/twigbridge/src/config/config.php.

You can quickly publish a configuration file by running the following Artisan command.

```
$ php artisan config:publish rcrowe/twigbridge

```

Usage
=====

[](#usage)

You call the Twig template like you would any other view:

```
// Without the file extension
View::make('i_am_twig', array(...))
```

TwigBridge also supports views in other packages:

```
View::make('pagination::simple')
```

The above rules continue when extending another Twig template:

```
{% extend "parent" %}
{% extend "pagination::parent" %}
```

You can call functions with parameters:

```
{{ link_to_route('tasks.edit', 'Edit', task.id, {'class': 'btn btn-primary'}) }}
```

And output variables, escaped by default. Use the `raw` filter to skip escaping.

```
{{ some_var }}
{{ html_var | raw }}
{{ long_var | str_limit(50) }}
```

Extensions
==========

[](#extensions)

Sometimes you want to extend / add new functions for use in Twig templates. Add to the `enabled` array in config/extensions.php a list of extensions for Twig to load.

```
'extensions' => array(
    'TwigBridge\Extensions\Example'
)
```

TwigBridge supports both a string or a closure as a callback, so for example you might implement the [Assetic](https://github.com/kriswallsmith/assetic) Twig extension as follows:

```
'extensions' => array(
    function($app) {
        $factory = new Assetic\Factory\AssetFactory($app['path'].'/../some/path/');
        $factory->setDebug(false);
        // etc.....
        return new Assetic\Extension\Twig\AsseticExtension($factory);
    }
)
```

TwigBridge comes with the following extensions enabled by default:

- [Twig\_Extension\_Debug](http://twig.sensiolabs.org/doc/extensions/debug.html)
- TwigBridge\\Extension\\Laravel\\Auth
- TwigBridge\\Extension\\Laravel\\Config
- TwigBridge\\Extension\\Laravel\\Form
- TwigBridge\\Extension\\Laravel\\Html
- TwigBridge\\Extension\\Laravel\\Input
- TwigBridge\\Extension\\Laravel\\Session
- TwigBridge\\Extension\\Laravel\\String
- TwigBridge\\Extension\\Laravel\\Translator
- TwigBridge\\Extension\\Laravel\\Url
- TwigBridge\\Extension\\Loader\\Facades
- TwigBridge\\Extension\\Loader\\Filters
- TwigBridge\\Extension\\Loader\\Functions

To enable '0.5.x' style Facades, enable the Legacy Facades extension:

- TwigBridge\\Extension\\Laravel\\Legacy\\Facades

FilterLoader and FunctionLoader
-------------------------------

[](#filterloader-and-functionloader)

These loader extensions exposes Laravel helpers as both Twig functions and filters.

Check out the config/extensions.php file to see a list of defined function / filters. You can also add your own.

FacadeLoader
------------

[](#facadeloader)

The FacadeLoader extension allows you to call any facade you have configured in config/extensions.php. This gives your Twig templates integration with any Laravel class as well as any other classes you alias.

To use the Laravel integration (or indeed any aliased class and method), just add your facades to the config and call them like `URL.to(link)` (instead of `URL::to($link)`)

Functions/Filters/Variables
---------------------------

[](#functionsfiltersvariables)

The following helpers/filters are added by the default Extensions. They are based on the helpers and/or facades, so should be self explaining.

Functions:

- asset, action, url, route, secure\_url, secure\_asset
- auth\_check, auth\_guest, auth\_user
- config\_get, config\_has
- form\_\* (All the Form::\* methods, snake\_cased)
- html\_\* (All the Html::\* methods, snake\_cased)
- input\_get, input\_old
- link\_to, link\_to\_asset, link\_to\_route, link\_to\_action
- session\_has, session\_get, csrf\_token
- str\_\* (All the Str::\* methods, snake\_cased)
- trans, trans\_choice
- url\_\* (All the URL::\* methods, snake\_cased)

Filters:

- camel\_case, snake\_case, studly\_case
- str\_\* (All the Str::\* methods, snake\_cased)
- trans, trans\_choice

Global variables:

- app: the Illuminate\\Foundation\\Application object
- errors: The $errors MessageBag from the Validator (always available)

Artisan Commands
================

[](#artisan-commands)

TwigBridge offers a command for CLI Interaction.

Empty the Twig cache:

```
$ php artisan twig:clean

```

Lint all Twig templates:

```
$ php artisan twig:lint

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

###  Release Activity

Cadence

Every ~15 days

Recently: every ~10 days

Total

41

Last Release

4299d ago

PHP version history (2 changes)v0.0.1PHP &gt;=5.3.0

0.6.0-beta1PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1711576?v=4)[Gencer W. Genç](/maintainers/gencer)[@gencer](https://github.com/gencer)

---

Top Contributors

[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (40 commits)")[![jwpage](https://avatars.githubusercontent.com/u/52687?v=4)](https://github.com/jwpage "jwpage (6 commits)")[![nils-werner](https://avatars.githubusercontent.com/u/88704?v=4)](https://github.com/nils-werner "nils-werner (3 commits)")[![jkazimir](https://avatars.githubusercontent.com/u/913745?v=4)](https://github.com/jkazimir "jkazimir (1 commits)")[![mikevrind](https://avatars.githubusercontent.com/u/594341?v=4)](https://github.com/mikevrind "mikevrind (1 commits)")[![Anahkiasen](https://avatars.githubusercontent.com/u/1321596?v=4)](https://github.com/Anahkiasen "Anahkiasen (1 commits)")[![winglian](https://avatars.githubusercontent.com/u/381258?v=4)](https://github.com/winglian "winglian (1 commits)")[![HellPat](https://avatars.githubusercontent.com/u/1016798?v=4)](https://github.com/HellPat "HellPat (1 commits)")[![JavierMartinz](https://avatars.githubusercontent.com/u/1155507?v=4)](https://github.com/JavierMartinz "JavierMartinz (1 commits)")

---

Tags

laraveltwig

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gencer-twigbridge-laravel-4/health.svg)

```
[![Health](https://phpackages.com/badges/gencer-twigbridge-laravel-4/health.svg)](https://phpackages.com/packages/gencer-twigbridge-laravel-4)
```

###  Alternatives

[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[delatbabel/viewpages

Support rendering/view of Laravel pages and templates from a database.

121.4k](/packages/delatbabel-viewpages)

PHPackages © 2026

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