Is it possible to exclude multiple directories when using Symfony autowire? Is it possible to exclude multiple directories when using Symfony autowire? symfony symfony

Is it possible to exclude multiple directories when using Symfony autowire?


In Symfony 4.1. But there is an closed bug and a pull request that may make this feature available for symfony 4.2 !


Excluding some directories bring some gain et efficiency for the service container initialization and service autoload processing ...

But, some others important features are also possible through that 'exclude' service configuration option :

  • IMHO, a very good motive of the 'exclude' option, permit also to manage PSR-4 autoloading conflict with internal bundles (under the src/ directory).
  • Excluding sub-directory block is the safe way to protect internal bundles namespace in the SF4 application. This also protect against autoloading conflicts between internal bundles and App bundle less part of SF4.

  • In your case, it's better to manually specify the path of each FolderToExclude, checking that there is no cross boundary with App subfolders.

  • If the number of sub-directories to exclude is too large for you to enumerate them individually, them you will surely have code design/organization problems to resolve at first.

Hope this help for your design decision.