PHPackages                             njh/twig-html-helpers - 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. njh/twig-html-helpers

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

njh/twig-html-helpers
=====================

Rails style view helpers for HTML tags in PHP Twig

137.2k7[1 PRs](https://github.com/njh/twig-html-helpers/pulls)PHP

Since Jan 26Pushed 4y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Twig HTML Helpers Extension
===========================

[](#twig-html-helpers-extension)

[![Build Status](https://camo.githubusercontent.com/49d732d9cc429e4a59830b368a0891ccd027ea300e9c95ea55dadf66951c240c/68747470733a2f2f7472617669732d63692e6f72672f6e6a682f747769672d68746d6c2d68656c706572732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/njh/twig-html-helpers)

This [PHP Twig](http://twig.sensiolabs.org) extension adds the following Rails style HTML helpers:

- `check_box_tag($name, $value = '1', $default = false, $options = array())`
- `content_tag($name, $content='', $options=array())`
- `hidden_field_tag($name, $default = null, $options = array())`
- `html_tag($name, $options=array())`
- `image_tag($src, $options=array())`
- `input_tag($type, $name, $value=null, $options=array())`
- `label_tag($name, $text = null, $options = array())`
- `labelled_text_field_tag($name, $default = null, $options = array())`
- `link_tag($title, $url=null, $options=array())`
- `password_field_tag($name = 'password', $default = null, $options = array())`
- `radio_button_tag($name, $value, $default = false, $options = array())`
- `reset_tag($value = 'Reset', $options = array())`
- `select_tag($name, $options, $default = null, $html_options = array())`
- `submit_tag($value = 'Submit', $options = array())`
- `text_area_tag($name, $default = null, $options = array())`
- `text_field_tag($name, $default = null, $options = array())`

To use them, first add the extension to your `composer.json`:

```
"require": {
    "njh/twig-html-helpers": "dev-master"
},

```

Then load it into your environment:

```
$twig = new Twig_Environment();
$twig->addExtension(new Twig_Extension_HTMLHelpers());

```

You can then use them in your Twig templates:

```
{{ link_tag('http://www.example.com/') }}

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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://www.gravatar.com/avatar/caf7e2a5536fc746a8b33c6e1baa4b7d7dbeef6d0620d27b0836ca85b65beed7?d=identicon)[njh](/maintainers/njh)

---

Top Contributors

[![njh](https://avatars.githubusercontent.com/u/38734?v=4)](https://github.com/njh "njh (33 commits)")

---

Tags

phpphp-twig

### Embed Badge

![Health badge](/badges/njh-twig-html-helpers/health.svg)

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

###  Alternatives

[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)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

555.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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