Is it possible to di compile to specific module instead of whole magento di compile ?

Because, Whole Magento take a long time to compile. So, is it possible to di compile to specific module.

php bin/magento setup:di:compile CompanyName_ModuleName

Please help me. If it is possible.


You can do this by follow this step :

Go to :


Find this line :

$modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);

Replace this below line and add path of the module which you want to compile like this :

$modulePaths = ['CompanyName_ModuleName' => '/var/www/html/YourMagento/app/code/CompanyName/ModuleName'];

Make sure module register with thisCompanyName_ModuleName in registration.php file.

It's temporary solution for di compile single module. Remove di generated module folder and refresh cache.

Hope, It will helpful for you.


| improve this answer | |
  • Happy to help !! Happy Coding :) – Rohan Hapani Jul 26 '18 at 18:46
  • 3
    excellent work....Suggest to create a custom command and implement the this logic – Amit Bera Jul 26 '18 at 19:39
  • 1
    Yes, a custom command that could be integrated in bin/magento or n98-magerun would be great – simonthesorcerer Aug 1 '18 at 11:46

If your focus is to try to contain as well as possible the downtime of your production, the below may help:

You could clone your codebase on the same server and separate folder (clone basically).

Once both environments would coexist, you can deploy static content on the clone without penalising the production environment uptime.

Finally, when the deploy is complete, you could either symlink the pub/static folder or just rsync. Of course, this may be done with a script.

| improve this answer | |

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.