We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
Get A List of All Modules Programatically
In this post we would have a look on how we can get a list of all modules programatically in Magento 2. Let's have a quick look!
Is well known that you can easily get a list of all enabled and disabled modules using the following cli command.
php bin/magento module:status
But what if you need to get this list in your code? For that you will need to use the classes Magento\Framework\Module\ModuleList and Magento\Framework\Module\FullModuleList.
Then the function that you will give that list is the getNames(). The getNames() function from the class Magento\Framework\Module\ModuleList, will give you back an array list with all enabled modules! The getNames() function from the Magento\Framework\Module\FullModuleList will give you back an array list with all modules (enabled and disabled).
Feel free to share this post and ask your questions in the comments below.
Till next time!