PHPackages                             chris-ware/bem-twig-extension - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. chris-ware/bem-twig-extension

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

chris-ware/bem-twig-extension
=============================

Twig function that inserts static classes in BEM methodology.

19.8kPHP

Since Jan 2Pushed 8y ago1 watchersCompare

[ Source](https://github.com/chris-ware/bem-twig-extension)[ Packagist](https://packagist.org/packages/chris-ware/bem-twig-extension)[ RSS](/packages/chris-ware-bem-twig-extension/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

bem-twig-extension
==================

[](#bem-twig-extension)

Twig function that inserts static classes in BEM methodology.

Based on \[\], but adapted to be available as a normal twig extension

Add Extension
-------------

[](#add-extension)

```
$twig = new Twig_Environment($loader, $options);
$twig->addExtension(new Bem\Twig\BemExtension());
```

Usage (4 arguments)
-------------------

[](#usage-4-arguments)

#### Simple block name (required argument):

[](#simple-block-name-required-argument)

``

This creates:

``

#### Block with modifiers (optional array allowing multiple modifiers):

[](#block-with-modifiers-optional-array-allowing-multiple-modifiers)

``

This creates:

``

#### Element with modifiers and blockname (optional):

[](#element-with-modifiers-and-blockname-optional)

``

This creates:

``

#### Element with blockname, but no modifiers (optional):

[](#element-with-blockname-but-no-modifiers-optional)

``

This creates:

``

#### Element with modifiers, blockname and extra classes (optional - in case you need non-BEM classes):

[](#element-with-modifiers-blockname-and-extra-classes-optional---in-case-you-need-non-bem-classes)

``

This creates:

``

#### Element with extra classes only (optional):

[](#element-with-extra-classes-only-optional)

``

This creates:

``

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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/671521?v=4)[Chris Ware](/maintainers/chrisware)[@chrisware](https://github.com/chrisware)

---

Top Contributors

[![chris-ware](https://avatars.githubusercontent.com/u/19684457?v=4)](https://github.com/chris-ware "chris-ware (1 commits)")[![chrisware-hs](https://avatars.githubusercontent.com/u/16339413?v=4)](https://github.com/chrisware-hs "chrisware-hs (1 commits)")

### Embed Badge

![Health badge](/badges/chris-ware-bem-twig-extension/health.svg)

```
[![Health](https://phpackages.com/badges/chris-ware-bem-twig-extension/health.svg)](https://phpackages.com/packages/chris-ware-bem-twig-extension)
```

###  Alternatives

[snowair/think-dotenv

ThinkPHP3.2集成php-dotenv

108.9k](/packages/snowair-think-dotenv)[rcastera/session

Session Class

212.2k1](/packages/rcastera-session)

PHPackages © 2026

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