PHPackages                             dyanakiev/litwig2020 - 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. dyanakiev/litwig2020

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

dyanakiev/litwig2020
====================

Twig Template for Laravel Framework, customized by me lol

1.5(5y ago)04MITPHPPHP ^7.3

Since May 30Pushed 5y agoCompare

[ Source](https://github.com/dyanakiev/litwig2020)[ Packagist](https://packagist.org/packages/dyanakiev/litwig2020)[ Docs](https://github.com/dinhquochan/laravel-twig)[ RSS](/packages/dyanakiev-litwig2020/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (14)Used By (0)

Laravel Twig - some personalization applied from the original package
=====================================================================

[](#laravel-twig---some-personalization-applied-from-the-original-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c64d61d8109cafdcabc226341178adedd5ddfde6a4d16b147f603cb8a8488436/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64696e6871756f6368616e2f6c61726176656c2d747769672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dinhquochan/laravel-twig)[![tests](https://github.com/dinhquochan/laravel-twig/workflows/tests/badge.svg)](https://github.com/dinhquochan/laravel-twig/workflows/tests/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/67c1a95063014669c4394209764dfcfad0ecba525a1c59ec5b07f7535037df1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64696e6871756f6368616e2f6c61726176656c2d747769672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dinhquochan/laravel-twig)

Allows you to use [Twig](https://twig.symfony.com/) in [Laravel](https://laravel.com/).

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2.0
- Laravel &gt;= 6.x

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dinhquochan/laravel-twig
```

If you don't use auto-discovery, add the Service Provider to the providers array in config/app.php

```
\DinhQuocHan\Twig\TwigServiceProvider::class,
```

If you want to use the facade to extended twig extensions, add this to your facades in app.php:

```
'Twig' => \DinhQuocHan\Twig\Facades\Twig::class,
```

So, we will use Artisan to add the new twig config file:

```
php artisan vendor:publish --provider="DinhQuocHan\Twig\TwigServiceProvider"

```

Usage
-----

[](#usage)

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

```
// Normal (template.html.twig or template.css.twig or template.twig)
return view('template', ['some_variable' => 'some_values']);

// With vender namespace
return view('vendor_namespace::template', $data);
```

Read more in [Twig for Template Designers](https://twig.symfony.com/doc/2.x/templates.html) or [Laravel Views](https://laravel.com/docs/5.7/views).

### Extending Twig

[](#extending-twig)

Laravel Twig allows you to define your own custom filters, functions, globals, token parsers or extensions.

The following example creates a `{{ product.price|money_format }}` filter which formats a given `$product->price`:

```
