定制 valerian/html 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

valerian/html

Composer 安装命令:

composer require valerian/html

包简介

Object oriented tool for building HTML documents.

README 文档

README

Object oriented tool for building HTML documents.

Requirements

Requires PHP 5.6.0 or higher.

Installation

The best way to install valerian/html is using Composer:

$ composer require valerian/html

Getting Started

Html

$element = (new Valerian\Html\Html())
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
    ->addChild(...)
echo (string) $element;

Output:

<html class="foo" id="bar"></html>

Body

$element = (new Valerian\Html\Body())
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
    ->addChild(...)
echo (string) $element;

Output:

<body class="foo" id="bar"></body>

Div

$element = (new Valerian\Html\Div())
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
    ->addChild(...)
echo (string) $element;

Output:

<div class="foo" id="bar"></div>

Span

$element = (new Valerian\Html\Span())
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
    ->addChild(...)
echo (string) $element;

Output:

<span class="foo" id="bar"></span>

Paragraph

$element = (new Valerian\Html\Paragraph())
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
    ->addChild(...)
echo (string) $element;

Output:

<p class="foo" id="bar"></p>

Image

$element = (new Valerian\Html\Img('image url'))
    ->alt('alt text')
    ->width(100)
    ->height(200)
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
echo (string) $element;

Output:

<img src="image url" alt="alt text" width="100" height="200" class="foo" id="bar">

Input

$input = (new Valerian\Html\Input('text', 'foo'))
    ->value('bar')
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
echo (string) $input;

Output:

<input type="text" name="foo" value="bar" class="foo" id="bar">

Select

$select = (new Valerian\Html\Select('foo'))
    ->addOption(
        (new \Valerian\Html\SelectOption(1, 'Option 1'))
            ->disabled('disabed')
    )
    ->addOption(
        (new \Valerian\Html\SelectOption(2, 'Option 2'))
    )
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
echo (string) $select;

Output:

<select name="foo" value="bar" class="foo" id="bar">
    <option value="1" disabled="disabed">Option 1</option>
    <option value="2">Option 2</option>
</select>

Form

$input = (new Valerian\Html\Form('#'))
    ->method('GET')
    ->attribute('class', 'foo')
    ->attribute('id', 'bar')
    ->addChild($input)
    ->addChild($select)
echo (string) $input;

Output:

<form action="#" method="GET" class="foo" id="bar">
    <input type="text" name="foo" value="bar" class="foo" id="bar">
    <select name="foo" value="bar" class="foo" id="bar">
        <option value="1" disabled="disabed">Option 1</option>
        <option value="2">Option 2</option>
    </select>
</form>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-12-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固