bpoiss

Magento, PHP, Java, C#

Magento2 xml validation on the fly

If you want your PhpStorm IDE to provide Magento2 xml validation on the fly, you now need to set up a misc.xml file in your .idea folder. In your misc.xml file you can configure how the URLs are mapped to the file locations of the Magento2 XSD files. Take the following xml as example:

<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Module/etc/module.xsd”>

The URL is “urn:magento:framework:Module/etc/module.xsd”. The place where PhpStorm is looking for a mapping to any file is the misc.xml file. Since you have not created one, or not inserted the mappings, it will not find the XSDs and on the fly validation won’t work.

Magento2 xml validation

There are different ways to let your IDE validate Magento2 XML files on the fly. If you have not installed the Magento2 PhpStorm Plugin already, I would recommend to use the bin/magento command line tool.

Magento2 PhpStorm Plugin

One way of creating a misc.xml file is to use the Magento2 PhpStorm Plugin. You can install it following the instructions on github. Once installed, you can simply click Preferences / Other Settings / Magento2 plugin -> Regenerate URN Map, and PhpStorm will automatically create the misc.xml file in your .idea folder.

bin/magento tool

Another way is to use the command bin/magento dev:urn-catalog:generate misc.xml. The syntax of the command is path/to/bin/magento dev:urn-catalog:generate targetFile. If your Magento2 installation and your development environment share the same host, you can directly choose your .idea/misc.xml file as targetFile. If your Magento2 installation lives in a VM, you have to generate the file and than sync it to your development machine.

2 Comments

  1. Hi guys,

    The links in this post seems to be broken.

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2019 bpoiss

Theme by Anders NorénUp ↑