PHPackages                             themosis/twig - 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. themosis/twig

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

themosis/twig
=============

Twig template engine support for Themosis.

101PHP

Since Sep 10Pushed 1y ago2 watchersCompare

[ Source](https://github.com/themosis/twig)[ Packagist](https://packagist.org/packages/themosis/twig)[ RSS](/packages/themosis-twig/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Twig
====

[](#twig)

This package adds the [Twig](https://twig.symfony.com/) template engine support for Themosis.

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

[](#installation)

Run the following command from your terminal in order to install the package:

```
composer require themosis/twig
```

Configuration
-------------

[](#configuration)

The package comes with a `twig.php` configuration file. If it's not automatically installed in your application, you can run the following command from your terminal:

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

Usage
-----

[](#usage)

This package provides the Twig engine to the View API coming with Laravel. Basically you can now create views using the `.twig` file extension instead of the `.php` or `.blade.php` extensions.

Twig views are located like any other views. All views directories, defined under the `config/view.php` configuration file `paths` property, can store Twig templates.

In order to control the Twig engine, you can modify its configuration under the `config/twig.php` file.

### Create a Twig view

[](#create-a-twig-view)

```
/**
 * From a controller method, return a Twig view:
 * This line is rendering the following view file `resources/views/welcome.twig`.
 */
return view('welcome');

/**
 * You can also render nested Twig views using the "." syntax.
 * This example is rendering the following view file `resources/views/pages/contact.twig`.
 */
return view('pages.contact');
```

### Pass data

[](#pass-data)

Just like any Blade views, you can pass data to a Twig view using the [same parameters](https://laravel.com/docs/views#passing-data-to-views) defined in the Laravel documentation:

```
/**
 * Passing data using the array parameter of the view function.
 */
return view('person', [
    'name' => 'Carla'
]);
```

Here is the `person.twig` file in action:

```

    {{ name }}

```

> You can also use the view [with()](https://laravel.com/docs/views#passing-data-to-views) method to pass data to your Twig template.

### Twig WordPress extension

[](#twig-wordpress-extension)

The package comes with a Twig `WordPressExtension`. Please refer to the [extension file](./src/Extensions/WordPressExtension.php) for details on available functions and filters provided by this extension in your Twig templates.

> Note the use of the `fn` global object that can help you call any PHP functions. For example: `fn.ucfirst('twig')`.

Notes
-----

[](#notes)

In order to learn the Twig template engine syntax, please refer to the official Twig documentation:

-

Credits
-------

[](#credits)

- [Julien Lambé](https://github.com/jlambe)
- [All Contributors](https://github.com/themosis/twig/contributors)

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f50d43fa42a64e828395bf8aff851be14c2278cfb6b364ba64880c45afa9c09?d=identicon)[jlambe](/maintainers/jlambe)

---

Top Contributors

[![jlambe](https://avatars.githubusercontent.com/u/1917490?v=4)](https://github.com/jlambe "jlambe (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/themosis-twig/health.svg)

```
[![Health](https://phpackages.com/badges/themosis-twig/health.svg)](https://phpackages.com/packages/themosis-twig)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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