masterminds/html5
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Masterminds/html5 is a standards-compliant HTML5 parser and writer designed exclusively in PHP. With over five million downloads, it offers stability and tested performance for a wide array of production websites. The package provides a host of features such as an HTML5 serializer, compatibility with PHP namespaces, support for Composer, an event-based parser akin to SAX, a DOM tree builder, and interoperability with QueryPath. It functions seamlessly with PHP versions 5.3.0 and above.
To utilize the masterminds/html5 package, you will first need to install it using Composer. This can be done by either adding the "masterminds/html5" as a dependency to your composer.json file or by invoking the require command that goes like "composer require masterminds/html5" via the composer executable.
Post-installation, there are two ways of using HTML5-PHP, via a high-level API or a low-level API. For a high-level application, you need to initiate an instance of HTML5 and use its object methods to load and save HTML content. View the below example:
<?php
require "vendor/autoload.php";
use Masterminds\HTML5;
$html = <<< 'HERE'
<html>
<head>
<title>TEST</title>
</head>
<body id='foo'>
<h1>Hello World</h1>
<p>This is a test of the HTML5 parser.</p>
</body>
</html>
HERE;
$html5 = new HTML5();
$dom = $html5->loadHTML($html);
print $html5->saveHTML($dom);
$html5->save($dom, 'out.html');
The package also allows users to pass an array of configuration options when loading an HTML5 document.
The documentation and deep-dive details for the masterminds/html5 package can be found directly on their GitHub repository page. The Readme file offers comprehensive instructions and examples for installation, usage (basic and advanced), package design, known issues, license details, and additional resources. Users can consult this page for any general troubleshooting or advanced tinkering with the package. The repo page also harbors unit tests for the API and each public function is well-documented for user comprehension.