PHPackages                             php-forge/html-helper - 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. php-forge/html-helper

ActiveLibrary

php-forge/html-helper
=====================

Awesome HTML Helpers Code Generator for PHP.

0.2.1(2y ago)12.2kmitPHPPHP ^8.1CI passing

Since Feb 28Pushed 2y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (8)Versions (5)Used By (0)

 [ ![](https://avatars.githubusercontent.com/u/121752654?s=200&v=4) ](https://github.com/php-forge/html-helper)

Awesome HTML Helpers Code Generator for PHP.
============================================

[](#awesome-html-helpers-code-generator-for-php)

 [ ![PHPUnit](https://github.com/php-forge/html-helper/actions/workflows/build.yml/badge.svg) ](https://github.com/php-forge/html-helper/actions/workflows/build.yml) [ ![Codecov](https://camo.githubusercontent.com/fbe833d42144edc9b310972424661f50cb31668b1ce10b8407f97eaa1912cbec/68747470733a2f2f636f6465636f762e696f2f67682f7068702d666f7267652f68746d6c2d68656c7065722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4d4630585547564c5943) ](https://codecov.io/gh/php-forge/html-helper) [ ![Infection](https://camo.githubusercontent.com/ae62d2fa7fc4ecf364f80da9297f9276f79d0bd2eea1ea393267f763921e5911/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532467068702d666f72676525324668746d6c2d68656c7065722532466d61696e) ](https://dashboard.stryker-mutator.io/reports/github.com/php-forge/html-helper/main) [ ![Psalm](https://github.com/php-forge/html-helper/actions/workflows/static.yml/badge.svg) ](https://github.com/php-forge/html-helper/actions/workflows/static.yml) [ ![Psalm Coverage](https://camo.githubusercontent.com/cb84140ed89968d8a14e783ec2d5438bf148c5cababbfe6a6704ecc96f7b6f7d/68747470733a2f2f73686570686572642e6465762f6769746875622f7068702d666f7267652f68746d6c2d68656c7065722f636f7665726167652e737667) ](https://shepherd.dev/github/php-forge/html-helper) [ ![Style ci](https://camo.githubusercontent.com/4ca2a226079ba9e6a3c4323c00ca623f8f6601317548d39d4c5aa1a44be07e03/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3736343637313331312f736869656c643f6272616e63683d6d61696e) ](https://github.styleci.io/repos/764671311?branch=main)

HTML Helper is a PHP library that simplifies the creation of HTML elements. It provides a set of classes to generate HTML attributes, encode content, sanitize HTML content, and more.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
composer require --prefer-dist php-forge/html-helper:^0.1
```

or add

```
"php-forge/html-helper": "^0.1"
```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

### Add CSS classes

[](#add-css-classes)

The `CssClasses::class` helper can be used to add CSS classes to an HTML element.

The method accepts three parameters:

- `attributes:` (array): The HTML attributes of the element.
- `classes:` (array|string): The CSS classes to add.
- `overwrite:` (bool): Whether to overwrite the `class` attribute or not. For default, it is `false`.

```
