Magento2 – How to Disable setup:di:compile

magento2modulesetup-di-compile

Maybe this is a very silly question. I can not understand why I must run the command setup:di:compile every time I make changes to custom modules, to see the results when I am in developer mode.

Can it be disabled?

Best Answer

You don't need to run it. You can simply delete the directories under var/generation (or under generated/ after 2.2). Be careful not to the delete the .htaccess file. You only really ever need to do this when you create a new constructor or change or reorder the arguments being passed into one of your class constructors.

For 2.2 and onwards, Magento documentation suggests using this command:

rm -rf <magento_root>/generated/metadata/* <magento_root>/generated/code/*