PHPackages                             aura/html - 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. aura/html

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

aura/html
=========

Provides HTML escapers and helpers, including form input helpers.

2.6.0(4y ago)52270.5k—3.7%22[3 PRs](https://github.com/auraphp/Aura.Html/pulls)20BSD-2-ClausePHPPHP &gt;=5.3.0CI failing

Since May 14Pushed 4mo ago12 watchersCompare

[ Source](https://github.com/auraphp/Aura.Html)[ Packagist](https://packagist.org/packages/aura/html)[ Docs](https://github.com/auraphp/Aura.Html)[ RSS](/packages/aura-html/feed)WikiDiscussions 6.x Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (20)

Aura.Html
=========

[](#aurahtml)

Provides HTML escapers and helpers, including form input helpers, that can be used in any template, view, or presentation system.

Foreword
--------

[](#foreword)

### Installation

[](#installation)

This library requires PHP 8.4 or later with at least one of the `mbstring` or `iconv` extensions. It has no userland dependencies.

It is installable and autoloadable via Composer as [aura/html](https://packagist.org/packages/aura/html).

### Quality

[](#quality)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/69652bfb5efbc19014cd76e9737e77de7364b0289b933f57bde597f78da5b87a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f617572617068702f417572612e48746d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d362e78)](https://scrutinizer-ci.com/g/auraphp/Aura.Html/)[![codecov](https://camo.githubusercontent.com/c5d638bce179455a2ff052eb045622effd01fe0205f9cb3965131c16fcd2b782/68747470733a2f2f636f6465636f762e696f2f67682f617572617068702f417572612e48746d6c2f6272616e63682f362e782f67726170682f62616467652e7376673f746f6b656e3d554153446f754c787963)](https://codecov.io/gh/auraphp/Aura.Html)[![Continuous Integration](https://github.com/auraphp/Aura.Html/actions/workflows/continuous-integration.yml/badge.svg?branch=6.x)](https://github.com/auraphp/Aura.Html/actions/workflows/continuous-integration.yml)

To run the unit tests at the command line, issue `composer install` and then `vendor/bin/phpunit` at the package root. This requires [Composer](http://getcomposer.org/) to be available as `composer`.

This library attempts to comply with [PSR-1](https://www.php-fig.org/psr/psr-1/), [PSR-12](https://www.php-fig.org/psr/psr-12/), and [PSR-4](https://www.php-fig.org/psr/psr-4/).

### Community

[](#community)

To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our [Google Group](http://groups.google.com/group/auraphp), follow [@auraphp on X](https://x.com/auraphp), or chat with us on #auraphp on Freenode.

Getting Started
---------------

[](#getting-started)

The easiest way to instantiate a *HelperLocator* with all the available helpers is to use the *HelperLocatorFactory*:

```

```

### Built-In Helpers

[](#built-in-helpers)

Once you have a *HelperLocator*, you can then use the helpers by calling them as methods on the *HelperLocator* instance. See the [tag helpers](https://github.com/auraphp/Aura.Html/blob/2.x/README-HELPERS.md) and [form helpers](https://github.com/auraphp/Aura.Html/blob/2.x/README-FORMS.md) pages for more information.

> N.b.: All built-in helpers escape values appropriately; see the various helper class internals for more information.

### Custom Helpers

[](#custom-helpers)

There are two steps to adding your own custom helpers:

1. Write a helper class
2. Set a factory for that class into the *HelperLocator* under a service name

A helper class needs only to implement the `__invoke()` method. We suggest extending from *AbstractHelper* to get access to indenting, escaping, etc., but it's not required.

The following example helper class applies ROT-13 to a string.

```

```

Now that we have a helper class, we set a factory for it into the *HelperLocator* under a service name. Therein, we create **and return** the helper class.

```

```

The service name in the *HelperLocator* doubles as a method name. This means we can call the helper via `$this->obfuscate()`:

```
