-- swilhelm <[email protected]> wrote (on Friday, 09 January 2009, 12:26 PM -0800): > > I have been Reading Cal Evan's Guide to Zend Framework Programming. > > In it he describes a Globals.php file for creating a single class to > encapsulate access to global resources like the database connection, cache > connection, config, etc. > > This seems useful, particularly if you use it in conjunction with his > Controller_Request_Cli class for exposing some of your Zend-based > application via command line or cron jobs. > > I was wondering if this is the recommended approach to exposing global > resources or is there a Zend Framework "approved" method?
I've had some back and forth with Cal on his Globals class. :) I personally feel that this is primarily the realm of a registry or dependency injection; a class of static methods is typically difficult to test against, and makes it more difficult to determine what the actual dependencies are for classes that pull from it. Zend_Application may very well make such a Globals class obsolete, as it will make it easier to handle your dependencies and push them either into the registry or directly into the objects that need them. -- Matthew Weier O'Phinney Software Architect | [email protected] Zend Framework | http://framework.zend.com/
