title: PHP Class Coupling with Global Settings
body: <p>I am in need of some advice with regards to the design pattern I use for a project I am working on. Let's say I have lots of classes which will use dependency injection and IoC containers for instantiation. A lot of these classes will rely on 'environmental' settings, such a memcached class relying on server locations, and SQL classes relying on SQL host details, but I'm not sure how to code this dependency. </p>
  
  <p>I could write these into the class, but it's not flexible. If I make the class utilize a global variable, I feel they are no longer loosely coupled and unit tests will be harder to complete. As such, how can I maintain a loose class coupling but maintain these settings from a central location?</p>
  
  <p>I don't want to have to dig through twelve PHP scripts to change each of the settings if the server setup alters.</p>
  
  <p>Ideally, I would like:</p>
  
  <ul>
  <li>Centralized settings and configurations</li>
  <li>Classes not implicitly coupled to external entities</li>
  <li>Ability to unit test still!</li>
  </ul>
  
  <p>Cheers!
  Adrian</p>