Download the PHP package seasonfive/html-validator without Composer

On this page you can find all versions of the php package seasonfive/html-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package html-validator

HTML Validator

A simple rule-based HTML validator that actually parses input HTML with an HTML5 parser.

Usually, taking HTML as input in the server-side is generally not a good idea, and in most cases, what you want is an HTML sanitizer. However, if you should, this HTML validator should come in handy.

Latest Version Build Status Total Downloads

Installation

Add the 'seasonfive/html-validator' to your composer.json file as follows:

or invoke composer require command (assuming composer binary is available in the path) as follows:

Usage

Errors

More detailed reports on what errors are encountered, if any, may be obtained if you pass a variable as follows:

Above, $errors is passed an array containing ValidationErrors and ParseError. ValidationError designates where in the HTML an error is occurred, and ParseError where parsing failed.

Disabling Fail Fast

In most cases, you would want Validator to report error as soon as it pinpoints the first one and stop further validation. However, it is also possible to continue to parse the input HTML and report all the errors at once as shown in the example in Errors section above, where the second argument to validate call is set to false. If not specified, Validator always fails fast.

Writing Rules

Rules for tags and attributes are specified in an array and given to the constructor of Validator. The rule array has tags and attrs keys, which contain rules for tags and attributes respectively. Note that any of them may be omitted meaning nothing is denied.

Allow/Deny

tags and attrs have another array as their values, the formats of which are identical. In the array, either allow or deny key may be specified. allow means only those specified explicitly allowed and all the others are denied ( that is, invalid). Conversely, deny means only explicitly specified ones are denied and all the others allowed.

Overrides

Optionally, overrides may be specified to override what is specified under either allow or deny. For instance, when allow is specified, overrides lists what must be denied. Usually more specific rules than those in allow or deny are listed there.

Tags and Attributes

In each of allow, deny, and overrides, tags and attributes are listed, where they can be nested as follows:

In tags array, the leaf (the deepest in the nested arrays) strings are tag names, and in attrs, attribute names. Nesting means the rule applies to the tag or attribute only if it is nested the same way as the rule. For example, in the above example, 'html' => ['body' => ['div' => 'onmouseover'] means the rule is effective only to onmouseover if it is specified to a div tag directly in a body, in turn, in an html tag.

Matcher

Instead of a string value, Matcher instance may be given as follows:

In the above example, TypeMatcher implements Matcher interface, and it may implement more sophisticated matching rule. The Matcher implements the following function, which gets called to see if a tag or attribute is actually matched, and the rule should be applied or not:

$context is given a TagContext for tags, and string values for attributes.


All versions of html-validator with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.0
masterminds/html5 Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package seasonfive/html-validator contains the following files

Loading the files please wait ....