Created
May 24, 2016 00:18
-
-
Save mfdj/f2ce8b21a74359cddf57a5e0a089ee09 to your computer and use it in GitHub Desktop.
shell function to scaffold a magento2 module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<< DOC | |
Usae: | |
mage2_module_scaffold <vendor> <module> | |
Note: | |
This command is destructive — it will ovewrite app/code/<vendor>/<module>/etc/module.xml | |
DOC | |
mage2_module_scaffold() { | |
local vendor=$1 | |
local module=$2 | |
local app_vendor_module=app/code/${vendor}/${module} | |
mkdir -p "$app_vendor_module/etc" | |
touch "$app_vendor_module"/{registration.php,etc/module.xml} | |
cat << EOF > "${app_vendor_module}/registration.php" | |
<?php | |
\Magento\Framework\Component\ComponentRegistrar::register( | |
\Magento\Framework\Component\ComponentRegistrar::MODULE, | |
'${vendor}_${module}', | |
__DIR__ | |
); | |
EOF | |
cat << EOF > "${app_vendor_module}/etc/module.xml" | |
<?xml version="1.0"?> | |
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | |
<module name="${vendor}_${module}" setup_version="0.0.1" /> | |
</config> | |
EOF | |
echo -n "bin/magento module:enable ${vendor}_${module}" | pbcopy | |
echo "Enable with 'bin/magento module:enable ${vendor}_${module}' (in clipboard)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment