Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shakhmehedi/b8c908f226bf9e6271976a80c8436f3b to your computer and use it in GitHub Desktop.
Save shakhmehedi/b8c908f226bf9e6271976a80c8436f3b to your computer and use it in GitHub Desktop.
Magento 2: How to get a module filesystem path programmatically From https://mage2.pro/t/topic/57
/**
* @param string $moduleName
* @param string $type [optional]
* @return string
* @throws \InvalidArgumentException
*/
function df_module_dir($moduleName, $type = '') {
/** @var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\Module\Dir\Reader $reader */
$reader = $om->get('Magento\Framework\Module\Dir\Reader');
return $reader->getModuleDir($type, $moduleName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment