I have a very simple question. Which magento commands cause the removal of


Folders and which bin/magento commands create them again.


2 Answers 2


var/cache is cleared by php bin/magento cache:flush. It rebuilds on the fly as data is cached by Magento (there's no command to rebuild, it just happens).

var/di and var/generation are cleared by php bin/magento setup:upgrade, or manually (like executing rm -rf var/di var/generation from site root--be very careful with this!). You can rebuild them by running the command php bin/magento setup:di:compile. If you are in non-production mode, you can leave them and Magento will rebuild the generated sources on the fly (but it'll be a little slower while that happens).


must be php bin/magento cache:flush command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.