ui-awesome/html-contracts

Shared interfaces for the UI Awesome HTML ecosystem: rendering, attribute management, element typing, and form controls.

Maintainers

Package info

github.com/ui-awesome/html-contracts

pkg:composer/ui-awesome/html-contracts

Transparency log

Statistics

Installs: 6 846

Dependents: 4

Suggesters: 0

Stars: 2

Open Issues: 0


README

UI Awesome

HTML Contracts for PHP


PHPStan Security

Contracts (interfaces) for the UI Awesome HTML ecosystem for PHP
Provides shared interfaces for rendering, attribute management, and form control typing across HTML packages.

Installation

composer require ui-awesome/html-contracts:^0.1

Interfaces

RenderableInterface

Core contract for any object that can be rendered as an HTML string. Extends Stringable.

<?php

declare(strict_types=1);

use UIAwesome\Html\Contracts\RenderableInterface;

final class MyTag implements RenderableInterface
{
    public function __toString(): string
    {
        return $this->render();
    }

    public function render(): string
    {
        return '<div>Hello</div>';
    }
}

AttributesInterface

Contract for objects that manage HTML attributes with an immutable API.

Methods: attributes(), class(), getAttribute(), getAttributes(), removeAttribute(), setAttribute().

FormControlInterface

Composed interface extending both RenderableInterface and AttributesInterface. Use this to type form control elements (inputs, selects, textareas, etc.) that need both rendering and attribute management.

<?php

declare(strict_types=1);

use UIAwesome\Html\Contracts\Form\FormControlInterface;

function renderField(FormControlInterface $control): string
{
    return $control->class('form-control')->render();
}

Documentation

For detailed configuration options and advanced usage.

Package information

PHP Latest Stable Version Total Downloads

Project status

PHPStan Level Max Quality StyleCI

Our social networks

Follow on X Follow on Facebook

License

License