Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
Put simply, a Dependency Injection Container alleviates the need for factories and the use of new in your code. Think of DiC as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts.
This module enables Symfony's Dependency Injection component for Drupal 7 modules.