Skip to content

ui-awesome/html-contracts

Repository files navigation

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

About

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

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

Generated from yii2-extensions/template