Matthias
24/11/2013

How to use an XML schema for PHPUnit configuration files to get autocompletion in PHPStorm

Back in 2011, one of our team members published an XML schema for the PHPUnit configuration file in his blog. And as of writing, it is among the top results when you google for "phpunit xsd".

Now it turned out that there is also an "official" schema available but mentioned nowhere in the docs.

That was easy to change and now folks will get the

<phpunit
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd" …

markup when they pick the example file from the documentation as a starting point.

Why?

Adding the schema definition is less important for validating the configuration file. The primary benefit is that every decent IDE should be able to give you autocompletion and code suggestions based on it.

When using PHPStorm, the schema URL will initially be displayed in red and marked as an error. You need to place the cursor on it, press Alt+Enter and choose "fetch external resource". After that, PHPStorm will keep a local copy of the schema file and use it also for every other project.

About Matthias

Avatar von Matthias Pigulla

Matthias Pigulla

Diplom-Wirtschaftsinformatiker, Geschäftsführer

Der strategische Kopf hinter unseren Softwaresystemen behält bei der Entwicklung und Betreuung komplexer Architekturen den Überblick, kümmert sich um die technische Infrastruktur oder berichtet über seine Erfahrungen und Erkenntnisse auf der Symfony User Group. Und wenn er abends damit fertig ist, entspannt der zweifache Vater entweder auf seiner Yogamatte oder lässt beim Fotografieren die Seele baumeln.

Was this helpful for you? Let @webfactory or @mpdude_de know!

Wir suchen Symfony-Entwickler*innen!

To top