Magento 2 setup:upgrade & Other Commands
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
- Changes to Setup script are made:
- InstallData
- InstallSchema
- UpgradeData
- UpgradeSchema
- At the time of the first Magento installation.
- At the time of a new module installation.
- 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:
1 |
php bin/magento setup:static-content:deploy |
Its short form is:
1 |
php bin/magento s:s:d |
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:
1 |
php bin/magento setup:di:compile |
Its short form is:
1 |
php bin/magento s:d:c |
In case of changes applied to admin configuration, layout xml, ui component, phtml, or any similar files, flush cache. Run the following command:
1 |
php bin/magento cache:flush |
Its short form is:
1 |
php bin/magento c:f |
We hope this post was useful. It is based on the