title: Dependency injection: should I inject everything or use a service locator for some objects?
body: <p>I'm currently refactoring my Zend Framework based PHP library from using a service locator to (constructor) dependency injection (DI). I feel that it improves my code a lot, but I'm not sure if I should inject all dependencies. A service locator seems easier for dependencies which are used a lot and are unspecific. I have the following dependencies which I still access using a service locator:</p>
  
  <ol>
  <li>A Zend_Translate object (I need to translate messages everywhere).</li>
  <li>A Zend_Locale object (stores the current language)</li>
  <li>A Zend_Config object (a lot of things are configurable by ini-file)</li>
  <li>Instances of utility classes (for array and string manipulation)</li>
  </ol>
  
  <p>If I injected these dependencies, they'd clutter my constructors and distract from the specific dependencies. For testing, I can just set up these dependencies in my service locator before running the tests. The pragmatist in me says I'm doing just fine, but the purist says I should go all the way with DI. </p>
  
  <p>Would you recommend DI for these types of objects or not?</p>