Hi Matthew,

Yes, we've had this discussion before.  :)  When I wrote the first edition
of the book I believe it was a good practice. Now however, I believe that
there are better ways to accomplish the goals of Globals.php.

The goals of Globals.php were 2 fold.
1) A central repository for application level variables
2) Lazy loading for certain classes like DB and Cache.

Registry does indeed handle #1 nicely and I'll be using that in the second
edition.  As you know (because you showed me how) I've also solved the DB
problem.  The only piece I've not yet completed is the lazy loading of
caching.  I think a similar solution to DB will work, I've just not done it
yet.  :)

I'm anxiously awaiting Zend_Application. That could change everything.

=C=


On Sat, Jan 10, 2009 at 5:31 AM, Matthew Weier O'Phinney
<[email protected]>wrote:

> -- 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/
>

Reply via email to