-- HMunroe <
harry.munroe@...> wrote
(on Thursday, 28 August 2008, 05:49 AM -0700):
> Matthew Weier O'Phinney-3 wrote:
> >
> > First, you _can_ use the $_request property directly. However, if you
> > ever modify getRequest() in your class or in a custom base controller
> > class, then you may be accessing the wrong property or overriding
> > necessary business logic. For this reason, we recommend using
> > getRequest() to grab the request object. (This is good OOP practice,
> > btw.)
> >
> I understand that, and I am OK with it (and I welcome all the new features
> added like the params stuff), but the example I gave is with $_SERVER and
> not $_REQUEST. And it is a good OOP practice, but in this case is a way too
> much for something so simple.
I mainly highlighted that as I anticipated others raising the question
of why getRequest() is used over _request.
BTW, $_REQUEST != the request object. The request object encapsulates a
variety of sources, including the various sources used by $_REQUEST, but
also $_SERVER, $_ENV, etc. This simplifies access to a variety of
sources, as well as provides abstraction and encapsulation, allowing
you to seamlessly switch between environments.
It may seem overkill for "something so simple", but often using $_SERVER
is oversimplification and non-portable.
> Matthew Weier O'Phinney-3 wrote:
> > Next, using isPost() is more portable than using
> > $_SERVER['REQUEST_METHOD']. The reasons are that your web server may or
> > may not populate this environment variable, and for testing. With
> > testing, we allow you to specifically set the request method -- $_SERVER
> > is never modified in this case. This gives you the ability to test your
> > applications without needing a web server involved.
> >
> I see, it's cool.
--
Matthew Weier O'Phinney
Software Architect |
matthew@...
Zend Framework |
http://framework.zend.com/