承接 danielescherzer/html-builder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

danielescherzer/html-builder

最新稳定版本:v0.0.2

Composer 安装命令:

composer require danielescherzer/html-builder

包简介

Tools for building HTML

README 文档

README

About

This composer library implements a set of utilities for build HTML output in PHP. It provides a fluent interface for manipulating attributes and building up the output.

Installation

The library is meant to be installed via composer, e.g. using composer require danielescherzer/html-builder.

Usage

Strings used are escaped automatically, special handling is available for boolean and space-separated attributes. The primary entry point is the use of the FluentHTML class:

use DanielEScherzer\HTMLBuilder\FluentHTML;

$result = FluentHTML::fromTag( 'form' )
    ->setAttribute( 'id', 'submission-form' )
    ->setAttribute( 'class', [ 'my-project-forms', 'example-form' ] )
    ->addChild(
        FluentHTML::fromTag( 'label' )
            ->setAttribute( 'for', 'username-input' )
            ->addChild(
                '<username>'
            )
    )
    ->addChild(
        FluentHTML::fromTag( 'input' )
            ->setAttribute( 'type', 'text' )
            ->setAttribute( 'name', 'username' )
            ->setAttribute( 'id', 'username-input' )
    )
    ->addChild(
        FluentHTML::fromTag( 'button' )
            ->setAttribute( 'type', 'submit' )
            ->setAttribute( 'disabled', true )
            ->addClass( 'btn-submit' )
            ->addChild( 'Submit' )
    )
    ->getHTML();

results in the following HTML (split across multiple lines for readability):

<form id="submission-form" class="my-project-forms example-form">
    <label for="username-input">&lt;username&gt;</label>
    <input type="text" name="username" id="username-input">
    <button type="submit" disabled class="btn-submit">Submit</button>
</form>

统计信息

  • 总下载量: 653
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-26