0

I'm trying to understand how compilation works in Magento 2 with regards to default mode, developer mode, and production mode.

The docs state that auto compilation is enabled in developer mode, which I assume negates the need to run setup:di:compile? In default mode, I'm not sure how compilation is handled. For production mode, I assume you need to re-run setup:di:compile if changes are made for those to materialize?

3

If you don't run setup:di:compile or clean var/di, DI will work same in all mode. If you run setup:di:compile and enable production mode, DI will get information from compiled files from var/di.

1

Theorically you don't need (and you shouldn't) to run setup:di:compile when in developer mode. However, once you do that, Magento will generate the compiled classes under /generated/code (/var/generated in older versions). You can delete the content under generated/code/* and generated/metadata/* at any time (when in developer mode).

When you enable the production mode, the compilation will start automatically (unless --skip-generation is passed to deploy:mode:set).

You can find more information on the links below:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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