Validate your XML files against Magento 2 XSD schemas

Annoyed by red attributes in your XMLs edited by your favourite IDE? There is an easy trick get rid of that and validate your XMLs against Magento 2 XSD schemas.

In your project root, run following command:

bin/magento dev:urn-catalog:generate .idea/misc.xml

This will generate misc.xml file in your .idea folder. If you open it you should see something like this:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectResources">
    <resource url="urn:magento:framework-message-queue:etc/consumer.xsd" location="$PROJECT_DIR$/vendor/magento/framework-message-queue/etc/consumer.xsd" />
    .
    .
    .
  </component>
</project>

Based on that your IDE (PHPStorm in our case) will validate your XMLs against Magento 2 XSD schemas.

You may also like

 16.5.2021
Unit testing Magento 1

Writing unit tests for Magento 1 running in Docker Container

 29.12.2022
XSD validation in your IDE

Validate your XML files against Magento 2 XSD schemas

 29.3.2022
Debugging Magento CLI running in Docker container

Debugging Magento CLI running in Docker container