Whenever I made any changes on the construction method, I need to do bin/magento setup:di:compile to get any changes on my code. It was wasting my time, how can I get any changes faster than have to run that command, please?

enter image description here

  • +1 for answer acceptance :) – Shoaib Munir Jul 23 '19 at 9:21

setup:di:compile => Generates DI (Dependency injection) configuration and all missing classes that can be auto-generated

So whenever you change in constructor you need to run setup:di:compile command to generate auto-generated interceptor files in generated directory.

If you want to bypass this one for development phase you can edit it's interceptor file located in generated/code/Vendor/Module/...

| improve this answer | |
  • Once I delete all files inside generated directory by running rm -rf generated/*, it works fine on a hello world site (example site), without me running setup:di:compile. Is there any affect if it's on a big site (real project)? But at the end of developing site, I always run setup:di:compile. – Fiko iCube Jul 23 '19 at 0:53
  • it wont affect anything unless you are on development mode, once you switch to production mode you always need to run di compile after every changes in parameters. You rm -rf trick would work on development mode. – Shoaib Munir Jul 23 '19 at 4:06
  • I would suggest once you make your changes on production server then change mode to production – Shoaib Munir Jul 23 '19 at 4:06
  • Awesome, thank you so much. – Fiko iCube Jul 23 '19 at 9:21

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.