There is no need to create a Magento custom module structure from the scratch manually.

Using this great tool helps to make module creation process faster:

https://github.com/netz98/n98-magerun2

1. download and install n98-magerun2 as described on above link.

2. navigate to Magento root directory using the terminal.

3. running command:


$ n98-magerun2.phar dev:module:create

will display the following message with instructions about parameters that can be used for Module creation:


dev:module:create [-m|--minimal] [--add-blocks] [--add-helpers] [--add-models] [--add-setup] [--add-all] [-e|--enable] [--modman] [--add-readme] [--add-composer] [--author-name[="..."]] [--author-email[="..."]] [--description[="..."]] vendorNamespace moduleName

For minimal module structure, we can run:


$ n98-magerun2.phar dev:module:create -m Apiworks Minimal

which will produce the following output:

image1

Apiworks/Minimal/etc/module.xml


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Apiworks_Minimal" setup_version="1.0.0">
        <sequence>
        </sequence>
    </module>
</config>

Apiworks/Minimal/registration.php


<?php
 
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Apiworks_Minimal',
    __DIR__
);


Leave a Reply

Your email address will not be published. Required fields are marked *