Download the PHP package webignition/html-document-type without Composer
On this page you can find all versions of the php package webignition/html-document-type. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webignition/html-document-type
More information about webignition/html-document-type
Files in webignition/html-document-type
Package html-document-type
Short Description For parsing, validating and creating HTML doctype strings
License MIT
Homepage https://github.com/webignition/html-document-type
Informations about the package html-document-type
For parsing, validating and creating HTML doctype strings (in PHP)
Tested against PHP 5.6, 7, 7.1 and 7.2.
Have you ever found yourself thinking:
- My life would be easier if I could programmatically create a doctype string
- I'd be happier if I could parse a doctype string into its component parts
- How can I get a doctype string from a HTML document?
- Is this doctype string that I'm staring at valid?
- I really need get the FPI and URI from this document string and I just don't know how!
Does that apply to you? If so, my goodness are you in luck.
- Usage
- Creating
- Parsing
- Getting a doctype string from a HTML document
- Creating a
HtmlDocumentType
object from a doctype string - Validating
- Developing
- Cloning
- Testing
Usage
Creating
Parsing
If you already know the component parts of a doctype you might as well just create a string.
What is often more useful is taking an existing doctype string and parsing it into its component parts.
Getting a doctype string from a HTML document
Parsing a doctype string requires a doctype string. One of the most common places to find a doctype string is in a HTML document.
Creating a HtmlDocumentType
object from a doctype string
You can extract the doctype string from a HTML document, but what do you then do with it? One option is to create a HtmlDocumentType
object.
Validating
Two of the component parts of a doctype are particularly relevant to validation: the fpi
and the uri
. There are known set of valid fpi
values. For each valid fpi
, there are a known set of valid uri
values.
Need to check that your doctype's fpi
is valid that the corresponding uri
is valid for that fpi
?
Developing
Cloning
You will need git
to clone and composer
to retrieve dependencies. I'm assuming both are in your path. Adjust as required.
Testing
This project uses phpcs
to check for PSR2 coding standards and phpunit
for running the tests. Both are installed by composer as dev dependencies.
Composer scripts are present to run CS checks, to run tests or to run both.