PHPackages                             beutnagel/doctype-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. beutnagel/doctype-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

beutnagel/doctype-validator
===========================

Check for valid W3C compliant DOCTYPEs

0.1.2-alpha(9y ago)122[10 issues](https://github.com/beutnagel/Doctype-Validator/issues)MITPHPPHP &gt;=5.4.0

Since Nov 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/beutnagel/Doctype-Validator)[ Packagist](https://packagist.org/packages/beutnagel/doctype-validator)[ Docs](https://github.com/beutnagel/Doctype-Validator)[ RSS](/packages/beutnagel-doctype-validator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

\#Doctype Validator Test to see if an HTML doctype is valid according to the W3C specifications.

See more at:

[![](https://camo.githubusercontent.com/114df8ebcaa63d6e695eb14b3439cb803fe77676519fe97a377fcb8b962de4f8/68747470733a2f2f636f6465736869702e636f6d2f70726f6a656374732f66663635643837302d386135352d303133342d396562322d3561376339616366353665382f7374617475733f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/114df8ebcaa63d6e695eb14b3439cb803fe77676519fe97a377fcb8b962de4f8/68747470733a2f2f636f6465736869702e636f6d2f70726f6a656374732f66663635643837302d386135352d303133342d396562322d3561376339616366353665382f7374617475733f6272616e63683d6d6173746572)

[![Latest Stable Version](https://camo.githubusercontent.com/29d83e72f4f31bf60d67187dee434c0398efd3308578ffa0d3dfccf3f6d554d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626575746e6167656c2f646f63747970652d76616c696461746f722e737667)](https://packagist.org/packages/beutnagel/doctype-validator)[![Total Downloads](https://camo.githubusercontent.com/cbade792a6feec6334bb4af5035087d8ebe0744780ed4ef695f63bbe5d5c434a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626575746e6167656c2f646f63747970652d76616c696461746f722e737667)](https://packagist.org/packages/beutnagel/doctype-validator)[![Reference Status](https://camo.githubusercontent.com/ebe283ab3fadcb31af587bb6589488b733bfd5e2dd5ce757b9cf0a06603a482f/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f626575746e6167656c3a646f63747970652d76616c696461746f722f7265666572656e63655f62616467652e737667)](https://www.versioneye.com/php/beutnagel:doctype-validator/references)[![GitHub issues](https://camo.githubusercontent.com/e4df8f3e57bc85751cdce9c9d6d73b29c7416cedd9408ce9bef8a8df3b0f8a8e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f626575746e6167656c2f446f63747970652d56616c696461746f722e737667)](https://github.com/beutnagel/Doctype-Validator/issues)

[![GitHub](https://camo.githubusercontent.com/0d671f5f6759fe83ad27eaac4be50e48d51df6b8576e260495631e85dfd9667f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f626575746e6167656c2f446f63747970652d56616c696461746f72)](https://camo.githubusercontent.com/0d671f5f6759fe83ad27eaac4be50e48d51df6b8576e260495631e85dfd9667f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f626575746e6167656c2f446f63747970652d56616c696461746f72)

\##Installation##

Install with Composer

`$ composer require beutnagel/doctype-validator`

For the current alpha release

```
{
	"require": {
        "beutnagel/doctype-validator": "^0.1.1@alpha"
    },
    "minimum-stability": "alpha"
}
```

\##Basic Usage The `Doctype_Validator` can be used to check the validity of a doctype, find errors and match it with existing official doctypes.

1. First create an instance of the validator:

```
$dtv = new Doctype_Validator();
```

2. Assign the doctype you want to validate:

```
$doctype = "";
```

### Is it a valid doctype?

[](#is-it-a-valid-doctype)

Checking to see if a doctype is valid.

```
$valid = $dtv->validate($doctype)->isValid();
```

*@return boolean TRUE or FALSE.*

### Does it match an official doctype?

[](#does-it-match-an-official-doctype)

A check can be performed with `isMatch()` to see if there is a match.

```
$match = $dtv->validate($doctype)->isMatch();
```

*@return boolean TRUE or FALSE*

```
$matches = $dtv->validate($doctype)->matches();
```

*@return string of name of match, or NULL if no match.*

### Errors

[](#errors)

If a doctype is not valid, `Doctype_Validator` will try to analyse why it is not valid. A list of errors can be found in `Doctype_Error.php`.

A simple check if a doctype has errors in it can be performed by the `hasError()` function.

```
$error = $dtv->validate($doctype)->hasError();
```

*@return boolean TRUE or FALSE.*

You can retrieve errors with the `getErrors()` method.

```
$result  = $dtv->validate($doctype);
if($result->hasErrors())
{
  $errors = $result->getErrors();
}
```

*@return array of errors.*

### Fragments

[](#fragments)

The doctype will be dissected into smaller fragments and these can be access with `getFragments()`.

```
$fragments = $dtv->validate($doctype)->getFragments();
```

*@return array of fragmentens*

License
-------

[](#license)

Doctype Validator is licensed under the MIT License - see the `LICENSE` file for details

Author
------

[](#author)

Jarne W. Beutnagel -  - [beutnagel.dk](http://beutnagel.dk)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

3

Last Release

3460d ago

PHP version history (2 changes)v0.1.0-alphaPHP &gt;=5.3.0

0.1.2-alphaPHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/779879c71eb201d9975d818246703d009286085bc0ae567ac350f9c703517d18?d=identicon)[beutnagel](/maintainers/beutnagel)

---

Top Contributors

[![beutnagel](https://avatars.githubusercontent.com/u/1915772?v=4)](https://github.com/beutnagel "beutnagel (61 commits)")

---

Tags

validatorvalidationhtmlW3Cdoctype

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/beutnagel-doctype-validator/health.svg)

```
[![Health](https://phpackages.com/badges/beutnagel-doctype-validator/health.svg)](https://phpackages.com/packages/beutnagel-doctype-validator)
```

###  Alternatives

[vlucas/valitron

Simple, elegant, stand-alone validation library with NO dependencies

1.6k4.4M128](/packages/vlucas-valitron)[wixel/gump

A fast, extensible &amp; stand-alone PHP input validation class that allows you to validate any data.

1.2k1.3M30](/packages/wixel-gump)[particle/validator

Flexible and highly usable validation library with no dependencies.

2521.7M10](/packages/particle-validator)[phpexperts/datatype-validator

An easy to use data type validator (both strict and fuzzy).

141.1M2](/packages/phpexperts-datatype-validator)[codeonyii/yii2-at-least-validator

Validates at least one (or more) attributes.

28253.5k1](/packages/codeonyii-yii2-at-least-validator)[dragon-code/card-number

Generation and verification of card numbers using Luhn's algorithm.

6512.8k](/packages/dragon-code-card-number)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
