There are lots of situations in which I change some files in my module in the developer mode but the changes didn't take place in frontend until I run php bin/magento setup:upgrade
Just wanted to know when should we run setup:upgrade
command and what's the purpose of it in Magento 2?
It's just so strange for me, because every time I'm doing some changes, they won't be visible until after I run the setup:upgrade command. Even if I delete the var/cache, it's still not visible. Does anyone know any reason for this?
Best Answer
If you enabled one or more modules, then you will need to run
magento setup:upgrade
to update the database schema.By default,
magento setup:upgrade
clears compiled code and the cache. Typically, you usemagento setup:upgrade
to update components and each component can require different compiled classes.The optional
--keep-generated
option should be used only in limited circumstances by experienced system integrators.--keep-generated
should never be used in a development environment.Improper use of this optional parameter can cause errors during code execution.
UPDATE (07/10/17)
As the topic creator asked me:
var/cache
in Magento 2 is not enough to makes changes visible like Magento 1. In Magento 2, you will need to clearsvar/generation
(andvar/di
if you compiled code) after you made changes inside your code, especially whenever you change something inside the constructor.You will also need to clear
var/view_preprocessed
if you change something inside your template file (.phtml)The rest will goes to
var/cache
andvar/full_page_cache
Hope this helps.