Creating an install schema script (InstallSchema.php)
Now that we understand the flow of schema and data scripts and their relation to the module version number, let us go ahead and start assembling our InstallSchema
. We start by defining the app/code/Foggyline/Office/Setup/InstallSchema.php
file with (partial) content as follows:
namespace Foggyline\Office\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; class InstallSchema implements InstallSchemaInterface { public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); /* #snippet1 */ $setup->endSetup(); } }
InstallSchema
conforms to InstallSchemaInterface
, which requires the implementation of the install
method that accepts two parameters of type SchemaSetupInterface
and ModuleContextInterface
.
The install method is all that is required...