If you attempt to create a module with a front name like hello-world in Magento 2, you'll get an error that looks like this.

Invalid XML in file /Users/alanstorm/Sites/magento-2-with-keys/magento2/app/code/Pulsestorm/HelloPestle/etc/frontend/routes.xml:
Element 'route', attribute 'id': [facet 'pattern'] The value 
'hello-world' is not accepted by the pattern '[A-Za-z0-9_]{3,}'.

It seems like Magento doesn't want URL front names that have anything other than a number, letter, or underscore in them. It also forces front names to have three or more characters.

The number, letter, and underscore limitation make sense since a route ID is used to create a layout handle and "special" characters there may cause a problem. However, the three character limit is confusing.

Does anyone know the reason for this?

  • Maybe this is because of XSD validations that are in place. – Bhargav Mehta Jan 8 '16 at 9:47
  • 2
    @Bhargav Yes, but why is the XSD configured that way? – Alan Storm Jan 8 '16 at 19:17

The reason was to avoid messy declarations with too short identifiers (same as too short variable limitations in PHP code style analyzers).

It was applied to multiple field types. Route front name has this limitation by mistake. It will be fixed


change hello-world as hello_world

Valid characters are alphabet, numeric and _

  • This doesn't seem to answer the question? – Alan Storm Nov 16 '16 at 17:11

Yes, it's in .xsd (routerIdType, routeIdType, moduleNameType, beforeAfterType, routeFrontNameType). Reason is unknown.



  • 2
    I'm not interested in the technical details of how the limitation was implemented, I want to know why it's there in the first place. – Alan Storm Jan 8 '16 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.