What happened to var/generation and var/di folders upgarding upgrading to Magento 2.2.*?


If you are wondering what happened to var/generation and var/di after upgrading to Magento 2.2.* then you are in the same boat as most of others.

If you don’t use composer to upgrade Magento 2 and upgrade manually then you will see these folders on your server but will be empty but if you do use composer to upgrade then you will no longer see these folders.

You must be running the following command  several times and wondering why var/generation and var/di are still empty or where are those folder gone.

php bin/magento setup:di:compile

Don’t panic, it is just Magento team who has been restructuring / re-factoring and decided to move these folders.

var/generation has been moved to generated/code


var/di has been moved to generated/metadata

You can find code compilation classes in the MagentoSetupModuleDiAppTaskOperation namespace.

Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.