Magento 2 setup:upgrade & Other Commands

- Fire development, Magento 2

Magento 2 Development; Magento 2 tutorial

The following post will help you optimise your daily routine with Magento 2. If you are using  “bin/magento setup:upgrade too often, you’ve come to the right place. Below, we shed light on when to use the command. There are multiple situations when it is not necessary to spend your time on setup:upgrade.

You only need to run the setup:upgrade command

  1. Changes to Setup script are made: 
    • InstallData
    • InstallSchema 
    • UpgradeData 
    • UpgradeSchema
  1. At the time of the first Magento installation.
  2. At the time of a new module installation.
  3. After upgrading Magento version.

The setup:upgrade command checks the module version in setup_module table. If the version is not available or a new version is specified in module.xml, the command runs the setup script and adds the latest version number to the table.

If HTML, CSS, JS, or other files were modified, delete changed files from the pub/static folder or run the following command:

Its short form is:

For such changes as a new dependency in __construct() or any changes in di.xml, delete changed files from var/generation folder. Alternatively, you can run the following command:

Its short form is:

In case of changes applied to admin configuration, layout xml, ui component, phtml, or any similar files, flush cache. Run the following command:

Its short form is:

We hope this post was useful. It is based on the StackExchange question by Bunyamin and the answers by Prince Patel. For more useful articles, check out our Cookbook.