{"id":18794392,"url":"https://github.com/ui-awesome/html-interop","last_synced_at":"2026-02-21T17:04:48.600Z","repository":{"id":225973410,"uuid":"767397797","full_name":"ui-awesome/html-interop","owner":"ui-awesome","description":"UI Awesome HTML Common Interfaces for PHP.","archived":false,"fork":false,"pushed_at":"2024-03-09T11:31:23.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T08:02:01.261Z","etag":null,"topics":["html-interop","php","ui-awesome"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ui-awesome.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-05T08:18:40.000Z","updated_at":"2024-03-05T10:36:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"289671ab-17f9-40ff-bc0f-ce38f751a13d","html_url":"https://github.com/ui-awesome/html-interop","commit_stats":null,"previous_names":["ui-awesome/html-interop"],"tags_count":2,"template":false,"template_full_name":"yii-tools/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-awesome%2Fhtml-interop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-awesome%2Fhtml-interop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-awesome%2Fhtml-interop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-awesome%2Fhtml-interop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ui-awesome","download_url":"https://codeload.github.com/ui-awesome/html-interop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718440,"owners_count":19685742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-interop","php","ui-awesome"],"created_at":"2024-11-07T21:29:21.979Z","updated_at":"2026-02-21T17:04:48.595Z","avatar_url":"https://github.com/ui-awesome.png","language":"PHP","readme":"\u003c!-- markdownlint-disable MD041 --\u003e\n\u003cp align=\"center\"\u003e\n    \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_dark.png\"\u003e\n        \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_light.png\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_dark.png\" alt=\"UI Awesome\" width=\"150px\"\u003e\n    \u003c/picture\u003e\n    \u003ch1 align=\"center\"\u003eHtml interop\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\u003c!-- markdownlint-enable MD041 --\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eCommon interfaces and type-safe enums for HTML tag interoperability\u003c/strong\u003e\u003cbr\u003e\n    \u003cem\u003eProvides standardized contracts and tag collections for block, inline, list, root, table, and void elements.\u003c/em\u003e\n\u003c/p\u003e\n\n## Features\n\n\u003cpicture\u003e\n    \u003csource media=\"(min-width: 768px)\" srcset=\"./docs/svgs/features.svg\"\u003e\n    \u003cimg src=\"./docs/svgs/features-mobile.svg\" alt=\"Feature Overview\" style=\"width: 100%;\"\u003e\n\u003c/picture\u003e\n\n### Installation\n\n```bash\ncomposer require ui-awesome/html-interop:^0.3\n```\n\n### Quick start\n\n#### Using block-level HTML tags\n\nAccess standardized block-level tag names through the `Block` enum.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\Block;\n\necho Block::DIV-\u003evalue;\n// 'div'\n\necho Block::ARTICLE-\u003evalue;\n// 'article'\n\necho Block::SECTION-\u003evalue;\n// 'section'\n```\n\n#### Using inline-level HTML tags\n\nAccess standardized inline-level tag names through the `Inline` enum.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\Inline;\n\necho Inline::SPAN-\u003evalue;\n// 'span'\n\necho Inline::STRONG-\u003evalue;\n// 'strong'\n\necho Inline::A-\u003evalue;\n// 'a'\n```\n\n#### Using void (self-closing) HTML tags\n\nAccess standardized void element tag names through the `Voids` enum.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\Voids;\n\necho Voids::IMG-\u003evalue;\n// 'img'\n\necho Voids::INPUT-\u003evalue;\n// 'input'\n\necho Voids::BR-\u003evalue;\n// 'br'\n```\n\n#### Using specialized HTML tag collections\n\nUse specialized enums for list, root, and table elements.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\{Lists, Root, Table};\n\n// List elements\necho Lists::UL-\u003evalue;\n// 'ul'\n\necho Lists::OL-\u003evalue;\n// 'ol'\n\necho Lists::LI-\u003evalue;\n// 'li'\n\n// Root elements\necho Root::HTML-\u003evalue;\n// 'html'\n\necho Root::HEAD-\u003evalue;\n// 'head'\n\necho Root::BODY-\u003evalue;\n// 'body'\n\n// Table elements\necho Table::TABLE-\u003evalue;\n// 'table'\n\necho Table::THEAD-\u003evalue;\n// 'thead'\n\necho Table::TR-\u003evalue;\n// 'tr'\n\necho Table::TD-\u003evalue;\n// 'td'\n```\n\n#### Type safety with interfaces\n\nUse the provided interfaces to ensure type safety in your tag rendering implementations.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\BlockInterface;\n\n/**\n * Render HTML using any BlockInterface implementation.\n */\nfunction renderBlock(BlockInterface $tag, string $content): string\n{\n    return sprintf('\u003c%s\u003e%s\u003c/%s\u003e', $tag-\u003evalue, $content, $tag-\u003evalue);\n}\n\necho renderBlock(Block::DIV, 'Content');\n// \u003cdiv\u003eContent\u003c/div\u003e\n\necho renderBlock(Block::ARTICLE, 'Article content');\n// \u003carticle\u003eArticle content\u003c/article\u003e\n```\n\n#### Filtering and iterating tags\n\nLeverage PHP 8.1+ enum features for filtering and tag operations.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\Block;\n\n// Filter heading elements\n$headings = array_filter(\n    Block::cases(),\n    fn (Block $tag) =\u003e str_starts_with($tag-\u003ename, 'H'),\n);\n\nforeach ($headings as $heading) {\n    echo $heading-\u003evalue . PHP_EOL;\n}\n// h1\n// h2\n// h3\n// h4\n// h5\n// h6\n\n// Get all block tag names\n$tagNames = array_map(fn (Block $tag) =\u003e $tag-\u003evalue, Block::cases());\n```\n\n#### Extensibility\n\nCreate custom tag collections by implementing the core interfaces backed by string enums.\n\n- `\\UIAwesome\\Html\\Interop\\BlockInterface`: For container elements that have content and a closing tag.\n- `\\UIAwesome\\Html\\Interop\\InlineInterface`: For text-level elements.\n- `\\UIAwesome\\Html\\Interop\\VoidInterface`: For self-closing elements (no closing tag).\n\nYou can create custom enums for your specific domain (for example, SVG, MathML, or Web Components) and use them across multiple packages.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse UIAwesome\\Html\\Interop\\BlockInterface;\n\nenum SvgTag: string implements BlockInterface\n{\n    case SVG = 'svg';\n    case G = 'g';\n    case PATH = 'path';\n    // ... add other SVG block tags as needed\n}\n\n// Now you can use it with any BlockInterface-compatible renderer\nfunction renderAnyBlock(BlockInterface $tag, string $content): string\n{\n    return \"\u003c{$tag-\u003evalue}\u003e$content\u003c/{$tag-\u003evalue}\u003e\";\n}\n\necho renderAnyBlock(SvgTag::G, '...');\n// \u003cg\u003e...\u003c/g\u003e\n```\n\n## Documentation\n\nFor detailed configuration options and advanced usage.\n\n- 🧪 [Testing Guide](docs/testing.md)\n- 🛠️ [Development Guide](docs/development.md)\n\n## Package information\n\n[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge\u0026logo=php\u0026logoColor=white)](https://www.php.net/releases/8.1/en.php)\n[![Latest Stable Version](https://img.shields.io/packagist/v/ui-awesome/html-interop.svg?style=for-the-badge\u0026logo=packagist\u0026logoColor=white\u0026label=Stable)](https://packagist.org/packages/ui-awesome/html-interop)\n[![Total Downloads](https://img.shields.io/packagist/dt/ui-awesome/html-interop.svg?style=for-the-badge\u0026logo=composer\u0026logoColor=white\u0026label=Downloads)](https://packagist.org/packages/ui-awesome/html-interop)\n\n## Quality code\n\n[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge\u0026logo=github\u0026logoColor=white)](https://github.com/ui-awesome/html-interop/actions/workflows/static.yml)\n[![Super-Linter](https://img.shields.io/github/actions/workflow/status/ui-awesome/html-interop/linter.yml?style=for-the-badge\u0026label=Super-Linter\u0026logo=github)](https://github.com/ui-awesome/html-interop/actions/workflows/linter.yml)\n[![StyleCI](https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge\u0026logo=github\u0026logoColor=white)](https://github.styleci.io/repos/767397797?branch=main)\n\n## Our social networks\n\n[![Follow on X](https://img.shields.io/badge/-Follow%20on%20X-1DA1F2.svg?style=for-the-badge\u0026logo=x\u0026logoColor=white\u0026labelColor=000000)](https://x.com/Terabytesoftw)\n\n## License\n\n[![License](https://img.shields.io/badge/License-BSD--3--Clause-brightgreen.svg?style=for-the-badge\u0026logo=opensourceinitiative\u0026logoColor=white\u0026labelColor=555555)](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fui-awesome%2Fhtml-interop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fui-awesome%2Fhtml-interop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fui-awesome%2Fhtml-interop/lists"}