siriusphp / html
HTML rendering library with an API inspired by jQuery and React
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
Framework agnostic HTML rendering utility with an API inspired by jQuery and React.
Elevator pitch
$h = new Sirius\Html\Builder; $h->registerTag('user-login-form', 'MyApp\Html\Components\UserLoginForm'); echo $h->make('user-login-form', ['_form_values' => $_POST]);
which will output something like
<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>
Performance
There is a simple benchmark that renders a form with 4 fields and a button. Compared to Twig, Sirius HTML is 50% slower but uses 2x less memory.
The benchmark results are as follows for 100K iterations:
Of course, this is not a real world scenario, but it gives you an idea of what to expect from this library.