Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

PHPUnit Schema

The PHPUnit Schema file defines the rules by which a configuration file for PHPUnit may be structured. Schema aware XML Editors can provide content assist to authors. Using the Schema file is optional.

Validating your configuration file

The Schema file does not define a target namespace, so you should not need to modify your phpunit.xml if you just want to validate it. Just use a tool like xmllint to read in your configuration and validate it against the Schema, e.g.

 xmllint --schema phpunit.xsd phpunit.xml 

If you want to validate from a PHP file, you can use the DOM extension, e.g.

$dom = new DOMDocument;
if ($dom->schemaValidate('/path/to/phpunit.xsd')) {
    echo 'The document is valid';

Applying the Schema for Authoring

If you are using a Schema aware XML editor, you might want to apply the Schema file to your configuration file to get Content Assist and automatic validation when authoring the document.

To apply the Schema to a configuration file, you have to declare the Schema Namespace and the location of the Schema file in the phpunit.xml file. Since PHPUnit does not use a dedicated namespace for the configuration file, the following two lines are all that is required:

<?xml version="1.0" encoding="UTF-8"?>
    xsi:noNamespaceSchemaLocation="location of xsd file"

Getting a Single Schema file

The Schema file is currently split into multiple smaller files. This eases maintaining the Schema file during development. However, when working with PHPUnit, it might be undesired to have the entire folder structure in your project. For this reason, you can create a single phpunit.xsd with the PHP script given in the tools folder:

$ php generate-schema.php
Created new validated Schema file at:

If you do not want to checkout this project at all, you can also link against the pre-generated Schema files at or copy them from the gh-pages branch.

Additional Resources

The documentation of configuration files can be found in the official PHPUnit Manual

The class processing the configuration file is


No releases published


No packages published