The issue is there's no information about this topic in the Magento 2 documentation or anywhere else, so what's a Magento 2 library and what's its main difference compared with a Magento 2 module?
The only thing the Magento 2 documentation says about Magento 2 libraries is that they are installed under the folder /lib
instead of /app/code
.
What I have learned by looking at the code in some vendor modules is that Magento 2 libraries use the type ComponentRegistrar::LIBRARY
in their registration.php
and that there's no di.xml
in them but you can still use their classes in the di.xml
of other modules. See for example Magento\Framework\MessageQueue
which appears in /app/etc/di.xml
. Also, since they are not modules, there's no module.xml
in them.
But that's all. I'm looking for some insight as for when I should use a library instead of a module.