9

In Magento 2 (beta9 and above) you can run this command php bin/magento setup:di:compile and all the interceptors, factories and proxies (and maybe others) will be generated in the var/generation folder for all the classes you have in your magento instance.
This is useful for live environments because otherwise the classes mentioned above will be generated at runtime when they are needed and could impact performance.
Is there a way to exclude some classes from this script so the interceptors will not be created when running the command?
As an example: I want for the controller Magento\Backend\Controller\Adminhtml\Dashboard\RefreshStatistics not to have interceptors generated.

  • Why do you need this? – Anton Kril May 27 '15 at 6:49
  • @AntonKril. Stop asking questions and give me a solution :D. Now seriously, I'm trying to remove some modules and when doing so, the setup:di:compile fails because some parent classes are missing. The classes that extend those missing classes still exist but they are not used by the application. And I cannot remove them since they are in modules I need. See a full explanation below: magento.stackexchange.com/questions/69040/… – Marius May 27 '15 at 7:01
7

for running from cli at least in earlier versions there is the exclude-pattern parameter. It was added to avoid problems when a class cant be processed correctly, like it happens for example with magento1 classes. The commands and arguments may have changed by converting them to console commands.

But I am not sure what your goal is, so I cant say if this is a good solution to use.

  • Here is what I trying to do. I'm removing some modules to see how far I can go. Among these modules is the Report module. But because of the tight coupling between Reports and Backend module there are still classes in the backend module that depend on the report module classes. I found a way to not use them, but since the di command parses the files it goes through the "ignored" classes and tries to build the interceptors. But this fails because the parent class of Magento\Backend\Controller\Adminhtml\Dashboard\RefreshStatistics for example, does not exist. So I need a way to exclude this. – Marius May 27 '15 at 6:11
  • it seams that in the console command approach there is no exclude-pattern param. Or at least I didn't find it. I looked in DiCompileCommand::configure. – Marius May 27 '15 at 6:21
  • I see, you could add an Issue asking for this functionality refering to this PR: github.com/magento/magento2/pull/986 or you use the changeset there to test how to add it temporary for your local build. – Flyingmana May 27 '15 at 8:24

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.