Hello Magento Friends,
Magento 2 is a very modular eCommerce solution, and developers can easily extend its feature set with custom as well as third-party modules. Whether you are debugging, running system audits, or creating custom utilities, there may be times you want to get a full list of installed Magento 2 modules programmatically.

In this blog, we will guide you on how to retrieve all the modules in your Magento 2 store with an easy PHP script.
Steps to Get all Module List Programmatically in Magento 2:
Step 1: You need to create a “module.php“ file inside our extension at the following path
magento_root_directory\module.php
Then insert the code as below
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
try {
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$state = $obj->get(\Magento\Framework\App\State::class);
try {
$state->setAreaCode('frontend');
} catch (\Magento\Framework\Exception\LocalizedException $e) {
// Area code is already set, skip
}
$moduleList = $obj->get(\Magento\Framework\Module\ModuleListInterface::class);
$modules = $moduleList->getAll();
foreach ($modules as $moduleName => $moduleData) {
echo $moduleName . ' => Version: ' . $moduleData['setup_version'] . PHP_EOL;
}
} catch (\Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
Conclusion:
Retrieving a list of all modules in a Magento 2 store programmatically is an asset for developers and store admins as well. If you are creating a custom admin report, performing diagnostics, or checking for third-party modules, these functions enable you to retrieve module names and versions with ease.
How to get Module Version Programmatically in Magento 2
Have you applied this in your Magento development process? Share it in the comments.
Happy Coding!

FAQ
- What is the purpose of retrieving the module list in Magento 2?
Retrieving the module list is beneficial to admins and developers to see which modules and versions are installed and what modules are enabled or disabled, and also to resolve conflicts or performance issues.
- What is a module in Magento 2?
A module is a bundle of PHP code, XML configuration, layout files, templates, and static assets that provides a particular function of functionality—anywhere from a payment gateway to a small UI adjustment. Magento loads all enabled modules at runtime, so features of the platform are essentially a composite of all the activated modules.
- How can I quickly see which modules are enabled or disabled without writing code?
Run the built-in CLI command:
php bin/magento module:status
Enabled modules appear first, followed by a list of disabled ones.