Create A Module With Custom Database Table In Magento 2
Provided By Mageworld A Leading Magento Provider
OUTLINE
Step 1
• Create a new module (Tutorial_SimpleNews)
Step 2
• Create configuration file.
Step 3
• Create the installation file.
Step 4
• Activate the module.
Create a new table in the database of Magento 2 with the structure as follows:
Table name: tutorial_simplenews
Step 1: Create a new module (Tutorial_SimpleNews)
Step 2: Create configuration file.
Create file: app/code/Tutorial/SimpleNews/etc/module.xml
Purpose: declare the module
Step 3: Create the installation file.
Create file: app/code/Tutorial/SimpleNews/Setup/InstallSchema.php
Purpose: declare and create the custom table
=> Go to our blog tutorial for full source code
Step 4: Activate the module.
Active this module by opening:
app/etc/config.php file Add this line into it
Step 4.1:
Step 4: Activate the module.
Open the Command in
Windows
Go to Magento root
folder
Run this command line
to install module
Module: bin\magento setup:upgrade
Step 4.2:
Step 4: Activate the module. Step 4.3: Check database: the tutorial_simplenews table
is created successfully
Following Mageworld Magento2 Tutorial Series..