Creating an install data script (InstallData.php)

An install data script is what gets run immediately after upgrade schema. We define install data schema within the app/code/Foggyline/Office/Setup/InstallData.php file with (partial) content as follows:

namespace Foggyline\Office\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $employeeSetupFactory; public function __construct( \Foggyline\Office\Setup\EmployeeSetupFactory $employeeSetupFactory ) { $this->employeeSetupFactory = $employeeSetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface ...

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.