PHPackages                             jbzoo/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. [Templating &amp; Views](/categories/templating)
4. /
5. jbzoo/html

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

jbzoo/html
==========

HTML helper for easy way form building from any PHP code

1.0.0(10y ago)41.3k1[1 PRs](https://github.com/JBZoo/Html/pulls)MITPHPPHP &gt;=5.3.10

Since Feb 19Pushed 7y ago2 watchersCompare

[ Source](https://github.com/JBZoo/Html)[ Packagist](https://packagist.org/packages/jbzoo/html)[ RSS](/packages/jbzoo-html/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

JBZoo Html [![Build Status](https://camo.githubusercontent.com/72e861450989efa86589a30225578f7c7fa01a27e9ce8c3aa606e07415af781e/68747470733a2f2f7472617669732d63692e6f72672f4a425a6f6f2f48746d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/JBZoo/Html) [![Coverage Status](https://camo.githubusercontent.com/585bff0cf2d2e57fdfbc655c805e27bc615ac50d373f23eaf44b3c3b34d8f870/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f4a425a6f6f2f48746d6c2f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/JBZoo/Html?branch=master)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#jbzoo-html--------)

HTML helper for easy way form building from any PHP code.

[![License](https://camo.githubusercontent.com/4f3ce4ae171420095c9ca0ee6d75950a19376f0e9a032ad93f569c21aa0c8b43/68747470733a2f2f706f7365722e707567782e6f72672f4a425a6f6f2f48746d6c2f6c6963656e7365)](https://packagist.org/packages/JBZoo/Html) [![Latest Stable Version](https://camo.githubusercontent.com/37f10199c00db43d7c951f27b7c30c4ba45ed281f0ccf5ed2536e8cfec2aefeb/68747470733a2f2f706f7365722e707567782e6f72672f4a425a6f6f2f48746d6c2f762f737461626c65)](https://packagist.org/packages/JBZoo/Html) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/9f1dec3297a8b8f6299e2c03b636c550d1131ecb324bd4321e879a1e4454ba79/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a425a6f6f2f48746d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JBZoo/Html/?branch=master)

Install
-------

[](#install)

```
composer require jbzoo/html:"1.x-dev"  # Last version
composer require jbzoo/html            # Stable version
```

How to use?
-----------

[](#how-to-use)

```
require_once './vendor/autoload.php'; // composer autoload.php

// Get needed classes
use JBZoo\Html\Html;

echo Html::_('input')->render( /* ... */ ); // Underscore as factory

$html = Html::getInstance();                // Create or get pimple container
echo $html['input']->render( /* ... */ );   // As array
echo $html->input->render( /* ... */ );     // As object
```

1# Html button
--------------

[](#1-html-button)

---

#### 1.1 Simple button

[](#11-simple-button)

```
echo Html::_('button')->render('test', 'Button', array('title' => 'title attr'));
```

```
Button
```

#### 1.2 Change button type

[](#12-change-button-type)

```
echo Html::_('button')->render('test', 'Button', array(), 'reset');
```

```
Button
```

#### 1.3 Support UIkit CSS Framework button

[](#13-support-uikit-css-framework-button)

```
echo Html::_('button')->render('test', 'My button', array('button' => 'success', 'class' => 'my-class'));
```

```
My button
```

#### 1.4 Support UIkit CSS Framework icon

[](#14-support-uikit-css-framework-icon)

```
echo Html::_('button')->render('test', 'My button', array('button' => 'success', 'icon' => 'stop'));
```

```

     My button

```

2# Boolean elements
-------------------

[](#2-boolean-elements)

---

#### 2.1 Radio buttons

[](#21-radio-buttons)

```
echo Html::_('radiobool')->render('show', 0);  // 0 is "No" and 1 is "Yes"
```

```

     No

     Yes

```

#### 2.2 Single checkbox flag

[](#22-single-checkbox-flag)

```
echo Html::_('checkbool')->render(
    'show',                                 // Name
    0,                                      // Checked value
    array(                                  // Attrs
        'data-rel'   => 'tooltip',
        'data-title' => 'Checkbox title',
    )
);
```

```

      Yes

```

3# Elements with list of options
--------------------------------

[](#3-elements-with-list-of-options)

---

#### 3.1 Default checkbox template (No wrap)

[](#31-default-checkbox-template-no-wrap)

```
echo Html::_('checkbox')->render(
    array(                          // List of options
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',                         // Name
    array('val-1', 'val-3'),        // Checked values
    array('data-rel' => 'tooltip')  // Attrs
);
```

```

Label 1

Custom Label

Var 3
```

#### 3.2 Default wrap checkbox template

[](#32-default-wrap-checkbox-template)

```
echo Html::_('checkbox')->render(
    array(                          // List of options
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',                         // Name
    array('val-1', 'val-3'),        // Checked values
    array('data-rel' => 'tooltip')  // Attrs
);
```

```

     Label 1

     Custom Label

     Var 3

```

#### 3.3 Custom checkbox template

[](#33-custom-checkbox-template)

```
echo Html::_('checkbox')->render(
    array(                          // List of options
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',                         // Name
    'val-1',                        // Checked value
    array(),                        // Attrs
    function ($list, $name, $value, $id, $text, $attrs) {   // Custom render function
        $alias    = $value;
        $inpClass = 'jb-val-' . $alias;
        $input    = $list->input($name, $value, $id, $inpClass, $attrs);
        $text     = '' . $text . '';
        $label    = $list->label($id, $alias, $text);

        return implode(PHP_EOL, array($input, $label));
    }
);
```

```

    Label 1

    Custom Label

    Var 3

```

#### 3.3 Default checkbox template (No wrap)

[](#33-default-checkbox-template-no-wrap)

```
echo Html::_('radio')->render(
    array(                          // List value
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',                         // Checked value
    array('val-1', 'val-3'),
    array('data-rel' => 'tooltip')
);
```

```

Label 1

Custom Label

Var 3
```

#### 3.4 Default wrap checkbox template

[](#34-default-wrap-checkbox-template)

```
echo Html::_('radio')->render(
    array(                          // List of options
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',                         // Name
    'val-1',                        // Checked value
    array(),                        // Attrs
    true                            // Wrap input by label
);
```

```

     Label 1

     Custom Label

     Var 3

```

#### 3.5 Custom radio template

[](#35-custom-radio-template)

```
echo Html::_('radio')->render(
    array(
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',
    'val-1',
    array(),
    function ($list, $name, $value, $id, $text, $attrs) {
        $alias    = $value;
        $inpClass = 'jb-val-' . $alias;
        $input    = $list->input($name, $value, $id, $inpClass, $attrs);
        $text     = '' . $text . '';
        $label    = $list->label($id, $alias, $text);

        return implode(PHP_EOL, array($input, $label));
    }
);
```

```

    Label 1

    Custom Label

    Var 3

```

#### 3.5 Checked value is not exists

[](#35-checked-value-is-not-exists)

```
echo Html::_('radio')->render(
    array(                          // List of options
        'val-1' => 'Label 1',
        'val-2' => 'Custom Label',
        'val-3' => 'Var 3',
    ),
    'test',                         // Name
    'val-8',                        // Undefined value
    array(),                        // Atrs
    true                            // Wrap inputs by labels
);
```

```

     Label 1

     Custom Label

     Var 3

     Undefined

```

3# Data list
------------

[](#3-data-list)

---

```
echo Html::_('datalist')->render(
    array(                                  // Keys and Values
        'Label'        => 'Content text',
        'Custom label' => 'List text',
    ),
    array(                                  // Attrs
        'class' => 'test',
        'id'    => 'custom',
    )
);
```

```

    Label
    Content text
    Custom label
    List text

```

4# Selects
----------

[](#4-selects)

---

#### 4.1 Simple select list

[](#41-simple-select-list)

```
echo Html::_('select')->render(
    array(
        'val-1'  => 'Label 1',
        'test'   => 'Label test',
        'custom' => 'Custom',
    ),
    'test',
    'custom',
    array(
        'data-title' => 'My form select',
    )
);
```

```

    Label 1
    Label test
    Custom

```

#### 4.1 Multiple select

[](#41-multiple-select)

```
echo Html::_('select')->render(
    array(
        'val-1'  => 'Label 1',
        'test'   => 'Label test',
        'custom' => 'Custom',
        'simple' => 'Simple label',
        'moscow' => 'Moscow',
    ),
    'test',
    array('test', 'moscow'),
    array(
        'multiple' => true,
    )
);
```

```

    Label 1
    Label test
    Custom
    Simple label
    Moscow

```

#### 4.3 Selected option is not found

[](#43-selected-option-is-not-found)

```
/**
 * If selected params is array. For check selected option taken last array var.
 * If option is not exists created new option. See output.
 */
echo Html::_('select')->render(
    array(
        'val-1'  => 'Label 1',
        'test'   => 'Label test',
        'custom' => 'Custom',
        'simple' => 'Simple label',
        'moscow' => 'Moscow',
    ),
    'test',
    array('test', 'moscow', 'no-value')
);
```

```

    --No selected--
    Label 1
    Label test
    Custom
    Simple label
    Moscow

```

#### 4.4 Select with groups

[](#44-select-with-groups)

```
echo Html::_('select')->render(
    array(
        'val-1' => 'Label 1',
        'test'  => 'Test label',
        array(
            'gr-test' => 'Group test 1',
            'val-1'   => 'No exits in group',
        )
    ),
    'test',
    array('test', 'moscow', 'no-value')
);
```

```

    --No selected--
    Label 1
    Test label

        Group test 1

```

5# Hiddens fields
-----------------

[](#5-hiddens-fields)

---

#### 5.1 Single hidden input

[](#51-single-hidden-input)

```
echo Html::_('hidden')->render('image', 'my-value', 'my-class', 'unique', array('data-profile' => 'user-1'));
```

```

```

#### 5.2 Group of hidden inputs

[](#52-group-of-hidden-inputs)

```
echo Html::_('hidden')->group(array(
    'my-name' => 'My name value',
    'user'    => 'Administrator',
    'array'   => array(
        'value' => 'my value',
        'class' => 'array-hidden',
        'id'    => 'hide-id',
    ),
));
```

```

```

6# Iframe
---------

[](#6-iframe)

---

```
echo Html::_('iframe')->render('http://my-site.com/page', 'my-class', 'my-id', array('data-rel' => 'my-iframe'));
```

```

```

7# Textarea
-----------

[](#7-textarea)

---

```
echo Html::_('textarea')->render(
    'test',
    'Text area content',
    'my-class',
    'my-id',
    array(
        'data-rel'   => 'tooltip',
        'data-title' => 'Enter description',
    )
);
```

```
Text area content
```

7# Custom tag
-------------

[](#7-custom-tag)

---

```
echo Html::_('tag')->render('My content', 'custom-class', 'unique', array(
    'tag'   => 'div',
    'title' => 'Custom title'
));
```

```
My content
```

8# Data attr builder
--------------------

[](#8-data-attr-builder)

---

```
echo Html::_('input')->render(
    'test',
    'My value',
    '',
    '',
    array('data' => array(
        'test' => 'val',
        'json' => array(
            'param-1' => 'val-1',
            'param-2' => 'val-2',
        )
    ))
);
```

```

```

Unit tests and check code style
-------------------------------

[](#unit-tests-and-check-code-style)

```
make
make test-all
```

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.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

Unknown

Total

1

Last Release

3777d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/75e6de2785f6d099699f430ff58404af4fc0e83060d2953028c9664a54704a5f?d=identicon)[smetdenis](/maintainers/smetdenis)

---

Top Contributors

[![Cheren](https://avatars.githubusercontent.com/u/4447959?v=4)](https://github.com/Cheren "Cheren (40 commits)")[![SmetDenis](https://avatars.githubusercontent.com/u/1118678?v=4)](https://github.com/SmetDenis "SmetDenis (9 commits)")

---

Tags

htmlformrendercontrolsRendering

### Embed Badge

![Health badge](/badges/jbzoo-html/health.svg)

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

###  Alternatives

[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

66297.7k14](/packages/phug-phug)[laravie/html

HTML and Form Builders for the Laravel Framework

36185.1k4](/packages/laravie-html)[talesoft/tale-jade

A clean, lightweight and easy-to-use templating engine for PHP based on Jade/Pug

8819.3k5](/packages/talesoft-tale-jade)[view-components/view-components

Flexible Framework-Agnostic UI for Enterprise Web Applications

24107.0k7](/packages/view-components-view-components)[nextras/forms-rendering

Rendering helpers for Nette Framework Forms.

16102.5k2](/packages/nextras-forms-rendering)[vluzrmos/collective-html

LaravelCollective Html and Form builder for Lumen.

2223.9k](/packages/vluzrmos-collective-html)

PHPackages © 2026

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