Download the PHP package php-forge/html-helper without Composer
On this page you can find all versions of the php package php-forge/html-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-forge/html-helper
More information about php-forge/html-helper
Files in php-forge/html-helper
Package html-helper
Short Description Awesome HTML Helpers Code Generator for PHP.
License mit
Informations about the package html-helper
Awesome HTML Helpers Code Generator for PHP.
HTML Helper is a PHP library that simplifies the creation of HTML elements. It provides a set of classes to generate HTML attributes, encode content, sanitize HTML content, and more.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Usage
Add CSS classes
The CssClasses::class
helper can be used to add CSS classes to an HTML element.
The method accepts three parameters:
attributes:
(array): The HTML attributes of the element.classes:
(array|string): The CSS classes to add.overwrite:
(bool): Whether to overwrite theclass
attribute or not. For default, it isfalse
.
Overwriting the class
attribute:
Convert regular expression to pattern
The Utils::class
helper can be used to normalize a regular expression.
The method accepts one parameter:
regexp:
(string): The pattern to normalize.delimiter:
(string): The delimiter to use. For default, it isnull
.
Encode content
The Encode::class
helper can be used to encode HTML content.
The method accepts tree parameters:
content:
(string): The content to encode.doubleEncode:
(bool): Whether to double encode the content or not. For default, it istrue
.charset:
(string): The charset to use. For default, it isUTF-8
.
Encode value
The Encode::class
helper can be used to encode HTML value.
The method accepts tree parameters:
value:
(string): The value to encode.doubleEncode:
(bool): Whether to double encode the value or not. For default, it istrue
.charset:
(string): The charset to use. For default, it isUTF-8
.
Get short class name
The Utils::class
helper can be used to get the short class name.
The method accepts one parameter:
class:
(string): The class name to get the short name.suffix:
(string): Whether to append the::class
suffix to the class name. For default, it istrue
. If it isfalse
, the method will return the short name without the::class
suffix.lowercase:
(bool): Whether to convert the class name to lowercase or not. For default, it isfalse
.
Generate arrayable name
The ArrayableName::class
helper can be used to generate an arrayable name.
The method accepts one parameter:
name:
(string): The name to generate.
Generate input id
The Utils::class
helper can be used to generate an input id.
The method accepts tree parameters:
fieldModel:
(string): The name of the field model.property:
(string): The name of the property.charset:
(string): The charset to use. For default, it isUTF-8
.
Generate input name
The Utils::class
helper can be used to generate an input name.
The method accepts tree parameters:
fieldModel:
(string): The name of the field model.property:
(string): The name of the property.arrayable:
(bool): Whether the name is arrayable or not. For default, it isfalse
.
Sanitize content
The Sanitize::class
helper can be used to sanitize HTML content.
The method accepts one parameter:
content:
(...string|RenderInterface): The content to sanitize. It can be a string or an object that implements theRenderInterface::class
.
Render HTML attributes
The Attributes::class
helper can be used to render
HTML attributes in a programmatic way.
Render Template
The Template::class
helper can be used to render a template.
The method accepts two parameters:
template:
(string): The template to render.tokenValues:
(array): The token values to replace in the template.
\n
is a new line character, and it is used to separate the tokens in the template.
Validate value in list
The Validator::class
helper can be used to validate a value in a list.
The method accepts tree parameters:
value:
(mixed): The value to validate.exceptionMessage:
(string): The exception message to throw if the value is not in the list.list:
(...string): The list to validate the value.
Validate value iterable
The Validator::class
helper can be used to validate an iterable value. If the value is not iterable or null
, the
method will throw an InvalidArgumentException
.
The method accepts one parameter:
value:
(mixed): The value to validate.
Validate value numeric
The Validator::class
helper can be used to validate a numeric value. If the value is not numeric or null
, the method
will throw an InvalidArgumentException
.
The method accepts one parameter:
value:
(mixed): The value to validate.
Validate value scalar
The Validator::class
helper can be used to validate a scalar value. If the value is not scalar or null
, the method
will throw an InvalidArgumentException
.
The method accepts one parameter:
value:
(...mixed): The value to validate.
Validate value string
The Validator::class
helper can be used to validate a string value. If the value is not a string or null
, the method
will throw an InvalidArgumentException
.
The method accepts one parameter:
value:
(mixed): The value to validate.
Testing
Check the documentation testing to learn about testing.
Support versions
License
The MIT License (MIT). Please see License File for more information.
Our social networks
All versions of html-helper with dependencies
ext-mbstring Version *
php-forge/html-interop Version ^0.3
voku/anti-xss Version ^4.1