siriusphp / html
灵感来源于jQuery和React的API的HTML渲染库
2.0.0
2023-11-16 14:14 UTC
Requires
- php: >=8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.38
- pestphp/pest: ^2.24
- pestphp/pest-plugin-drift: ^2.5
- phpstan/phpstan: ^1.10
- rector/rector: ^0.18.8
- squizlabs/php_codesniffer: ^2.6
README
框架无关的HTML渲染工具,API灵感来源于jQuery和React。
简短介绍
$h = new Sirius\Html\Builder; $h->registerTag('user-login-form', 'MyApp\Html\Components\UserLoginForm'); echo $h->make('user-login-form', ['_form_values' => $_POST]);
它将输出类似以下内容
<form method="post" action="user/login" class="form form-inline"> <div class="form-control"> <label for="email">Email/Username:</label> <input type="email" name="email" id="email" value="me@domain.com"> </div> <!-- the rest of the form goes here --> </form>
性能
这里有一个简单的 基准测试,渲染一个包含4个字段和一个按钮的表单。与Twig相比,Sirius HTML速度慢50%,但内存使用量减少2倍。
对于100K次迭代的基准测试结果如下
当然,这并不是真实世界场景,但它可以给你一个对这个库的期望。