blackcube / html
Extensible HTML tags for Yii framework
Requires
- php: ^8.2
- yiisoft/html: ^4.2
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-25 08:54:43 UTC
README
Extensible HTML tags for Yii 3.
Version française : README.fr.md.
This package redeclares the tags, the widgets and the Html facade of
yiisoft/html, the work of the Yii
Software team released under the BSD-3-Clause License, without the final
keyword: see Credits.
Installation
composer require blackcube/html
Requirements
- PHP 8.2
- yiisoft/html
Nothing else: the package has no Blackcube dependency and works on its own.
What it is
Every tag of yiisoft/html is final. This package redeclares each of them, base
classes included, open to extension: same names, same methods, same
HTML, and the fluent methods return static so that a subclass keeps its
class through the calls.
It carries no semantics: no colour, no size, no CSS class. Those belong to the packages built on top of it.
Usage
Swap the use and keep the code:
use Blackcube\Html\Html; echo Html::a('Go', '/page')->addClass('link'); echo Html::ul()->strings(['one', 'two']); echo Html::checkboxList('colors')->items(['r' => 'Red', 'b' => 'Blue'])->value('b'); echo Html::openTag('div', ['class' => 'card']);
Html::a() returns a Blackcube\Html\Tag\A, Html::ul() a
Blackcube\Html\Tag\Ul, and so on: the facade exposes exactly the methods of
Yiisoft\Html\Html and produces the same HTML.
A tag is also built directly:
use Blackcube\Html\Tag\A; echo (new A())->href('/page')->target('_blank')->content('Go');
Extension
use Blackcube\Html\Tag\A; class Link extends A { } $link = (new Link())->href('/page'); // still a Link
The static factories use new static(): Link::hidden() on an Input
subclass returns the subclass. The facade itself can be extended.
Aurelia attributes
Blackcube\Html\Aurelia builds the attributes of an Aurelia 2 custom
attribute or custom element from a PHP array: camelCase keys become
kebab-case, a .bind / .trigger / … suffix on the key is kept as the
binding command, null values are skipped.
use Blackcube\Html\Aurelia; Aurelia::attributesCustomAttribute(['id' => 'myModal', 'url.bind' => '/api/user/1']); // "id: myModal; url.bind: '/api/user/1';" Aurelia::attributesCustomElement(['fieldName' => 'content', 'options.bind' => ['theme' => 'snow']]); // ['field-name' => 'content', 'options.bind' => '{"theme":"snow"}']
Tests
vendor/bin/codecept run
The tests cover what the package adds: extension and the Aurelia helper.
The rendering is yiisoft/html's, tested upstream.
Credits
The tags, widgets and facade are the work of the
Yii Software team, released under the
BSD-3-Clause License in yiisoft/html. They
are redeclared here without the final keyword and with static return
types; nothing else changes.
License
The code of this package is released under the BSD-3-Clause License. See LICENSE.md.
Copyright (c) 2026 Blackcube - Philippe Gaultier.
Author
Philippe Gaultier philippe@blackcube.io