File path: app/code/etc/modules/MageCheck_Tutorial.xml
File path: app/code/MageCheck/Tutorial/registration.php
File path: app/code/MageCheck/Tutorial/etc/module.xml
File path: app/code/community/MageCheck/Tutorial/etc/config.xml
File path: app/code/MageCheck/Tutorial/etc/config.xml
File path: app/code/community/MageCheck/Tutorial/Model/Resource/Ticket.php
File path: app/code/community/MageCheck/Tutorial/Model/Resource/Ticket/Collection.php
To enable custom module manually in Magento 2, two commands needs to be executed from the shell:
php bin/magento module:enable MageCheck_Tutorial
php bin/magento setup:upgrade
First command adds your module to the modules list in app/etc/config.php. Second one installs your module
If module has setup scripts, they are executed and current module version is saved in setup_module table. Magento regulates what needs setup by comparing module versions with what it sees in that table. If module is installing for the first time, Install + Upgrade scripts are triggered. If module was installed before, but module version is increased, only Upgrade scripts are triggered.
To disable module, you will run:
php bin/magento module:disable MageCheck_Tutorial
This will flag module as disabled in config.php.
To uninstall the module, you have to run the following command:
php bin/magento module:uninstall MageCheck_Tutorial
File path: app/code/community/MageCheck/Tutorial/sql/magecheck_tutorial_setup/install-184.108.40.206.php
File path: app/code/MageCheck/Tutorial/Setup/InstallData.php
File path: app/code/community/MageCheck/Tutorial/sql/magecheck_tutorial_setup/upgrade-220.127.116.11-18.104.22.168.php
Note: Do not forget to modify the version from config.xml file in order to upgrade your script.
File path: app/code/MageCheck/Tutorial/Setup/UpgradeData.php
Data setup scripts contain entries that the module needs to insert into the database. Attributes that come with Magento by default, 404 and other Cms pages, various default groups and roles, are all examples of data setup. Data setup is executed after Schema setup, they function in a similar fashion.
Recurring script is executed after any module setup. The idea is that Module1 can do something after Module2 and Module3 are installed, if needed. The only example in current Magento 2 is Magento\Indexer\Setup\Recurring class where Magento_Indexer module checks for new defined indexers and adds them to indexer_state table.
This works only with modules installed with Composer. Magento 2 modules can have Uninstall scripts. For example: