PHPackages                             redant/twig-components-bundle - 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. redant/twig-components-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

redant/twig-components-bundle
=============================

Twig Components bundle for Symfony

1.2.2(1y ago)818.7k↓33.3%2MITPHPPHP &gt;=8.0

Since Mar 1Pushed 1y ago2 watchersCompare

[ Source](https://github.com/redantnl/twig-components-bundle)[ Packagist](https://packagist.org/packages/redant/twig-components-bundle)[ RSS](/packages/redant-twig-components-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (17)Used By (0)

Twig Components
===============

[](#twig-components)

A Symfony bundle for the [Twig Components](https://github.com/redantnl/twig-components) library.

This bundle allows you to create robust, reusable and automatically documented Twig components using the new `component` tag. Twig components allow you to quickly build and maintain your own UI toolkit, where each button, table or card has to be designed only once and can be used throughout your entire application.

This Twig Components bundle for Symfony makes life a little bit easier by automatically searching your template directories for defined components, every time the Symfony container is compiled.

For more information about Twig Components, see [the documentation](https://github.com/redantnl/twig-components/blob/master/README.md).

Setup and Usage
---------------

[](#setup-and-usage)

You can install this bundle through Composer:

```
$ composer require redant/twig-components-bundle
```

When this bundle is enabled in your Symfony bundle configuration, if will search all your template directories for defined components, every time the container is compiled.

This includes:

- The `templates/components` folder (main application templates)
- Every installed bundle's `Resources/views/components` folder (if defined)

### Global variable

[](#global-variable)

If you don't like the name of the global variable that defines the components, use the `twig_components.global_variable` parameter to change this:

```
# app/config/twig.yaml

twig_components:
    global_variable: 'ui'
```

This will register the button component as `ui.button()`.

**Note**: If you set the prefix to `false`, no Twig global will be registered for defined components. You can then only use the `render_component` function.

### Namespaces

[](#namespaces)

If you define your components in subdirectories of the `components/` directory, the additional directories will namespace your component.

For example, a component defined in `components/ui/button.html.twig`will be accessible as `component.ui.button({})` or via `render_component('ui.button', {})`.

Generate documentation
----------------------

[](#generate-documentation)

The added bonus to creating component definitions is the automatic creation of documentation. It explains, for instance, what your component can be used for and which parameters it accepts. For example, the Twig Components bundle can automatically generate a table like this for an example button component:

PropertyTypeDefault valueCommentcontainer`string``button`HTML container elementclasses`string[]``[ 'small' ]`Additional button classeslabel\*`string`Button text (rendered as raw HTML)url`string`Hyperlinkconfirm`bool``false`You can generate a static HTML file with documentation using the supplied `twig:components:generate-docs` command.

```
Description:
  Generate documentation for Twig components

Usage:
  twig:components:generate-docs [options]

Arguments:
  path                  Output directory

Options:
  --title=TITLE         Title for the generated documentation [default: "Twig components"]
  --generic             Disregard twig_component.global_variable settings and only show render_component() examples```
```

**Pro tip**: When you start your component template file with a comment (`{# ... #}`), its contents will be added at the top of the documentation for the component.

License
-------

[](#license)

This library is licensed under the MIT License - see the LICENSE file for details.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance45

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 53.6% 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 ~150 days

Recently: every ~65 days

Total

15

Last Release

529d ago

Major Versions

0.1.5 → 1.0.02020-09-23

### Community

Maintainers

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

---

Top Contributors

[![ricohumme](https://avatars.githubusercontent.com/u/11029998?v=4)](https://github.com/ricohumme "ricohumme (15 commits)")[![cinamo](https://avatars.githubusercontent.com/u/7139230?v=4)](https://github.com/cinamo "cinamo (11 commits)")[![vicdelfant](https://avatars.githubusercontent.com/u/312664?v=4)](https://github.com/vicdelfant "vicdelfant (2 commits)")

---

Tags

symfony-bundletwig-extension

### Embed Badge

![Health badge](/badges/redant-twig-components-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)

PHPackages © 2026

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