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

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

dstone/twig-optimizations
=========================

Twig extensions which enable some experimental optimizations on compiled code

2311PHP

Since Nov 30Pushed 5y ago2 watchersCompare

[ Source](https://github.com/superdav42/TwigOptimizations)[ Packagist](https://packagist.org/packages/dstone/twig-optimizations)[ RSS](/packages/dstone-twig-optimizations/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

TwigOptimizations
=================

[](#twigoptimizations)

Twig extensions which enable some experimental optimizations on compiled code

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

[](#installation)

Add to composer

```
composer require dstone/twig-optimizations

```

Register extension in your twig envirnment with something like:

```
$twig->addExtension(new Twig_Optimizations_Extension_GetAttributeOptimizer());
```

If you are using symfony you can add it as a service definition in config.yml like:

```
services:
    twig.extension.optimizations:
        class: Twig_Optimizations_Extension_GetAttributeOptimizer
        tags:
            - { name: twig.extension }
```

Optimizations
=============

[](#optimizations)

The main optimization done at this time is elimnating the use of the Twig\_Template::getAttribute() when possible. Most of the work done by getAttribute involves looking at the type of the twig var and its defined methods. This extension records the class or type of each twig var passed to getAttribute the first time a template is rendered. Then it recompiles the twig template replacing getAttribute calls with a instanceof check and a direct call to the method or fallback to using getAttribute if the twig var uses a different type. The end result is most calls to getAttribute are removed but a few may remain if several different types of objects or arrays are used for a twig var in a template.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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://avatars.githubusercontent.com/u/1534605?v=4)[David Stone](/maintainers/superdav42)[@superdav42](https://github.com/superdav42)

---

Top Contributors

[![superdav42](https://avatars.githubusercontent.com/u/1534605?v=4)](https://github.com/superdav42 "superdav42 (11 commits)")

### Embed Badge

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

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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