Magento: How to get list of all modules programmatically?

Here, I will show you how you can get list of all modules in your Magento installation. It’s a simple code.

Get all modules

You can find getNode() function in the class Mage_Core_Model_Config.


$modules = Mage::getConfig()->getNode('modules')->children();

From the code above, you get all the modules information like whether the module is active or not, the codePool of the module, version of the module, etc.

Get all modules name

This code will list only the name of all the modules present in your Magento installation.


$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children()); 

Check whether any particular module is active

Suppose, I want to check whether Mage_Paypal module is active or not. The following code does the check.


$modules = Mage::getConfig()->getNode('modules')->children();
$modulesArray = (array)$modules;

if($modulesArray['Mage_Paypal']->is('active')) {
	echo "Paypal module is active.";
} else {
	echo "Paypal module is not active.";
}

Hope this helps. Thanks.