O'Reilly logo

Magento 2 Developer's Guide by Branko Ajzele

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an installation script (InstallSchema.php)

InstallSchema, or install script, is a way for us to set up tables in the database that will be used to persist our models later on.

If we look back at the module requirements, the following fields need to be created in the foggyline_helpdesk_ticket table:

  • ticket_id
  • customer_id
  • title
  • severity
  • created_at
  • status

Our InstallSchema is defined under the app/code/Foggyline/Helpdesk/Setup/InstallSchema.php file with (partial) content as follows:

<?php namespace Foggyline\Helpdesk\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; /** * @codeCoverageIgnore */ class InstallSchema implements InstallSchemaInterface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required