« Return to Thread: $this->getRequest()->isPost() vs. ($_SERVER['REQUEST_METHOD'] == 'POST')

Re: $this->getRequest()->isPost() vs. ($_SERVER['REQUEST_METHOD'] == 'POST')

by weierophinney :: Rate this Message:

Reply to Author | View in Thread

-- HMunroe <harry.munroe@...> wrote
(on Thursday, 28 August 2008, 08:34 AM -0700):

> Matthew Weier O'Phinney-3 wrote:
> >
> > 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.
>
> I am sorry, but I am not sure I follow -- what *other* environments ? Are
> you talking about CLI applications ?

CLI, GTK, and, most importantly, unit tests, which are typically run via
CLI, but which usually setup their own environment. In the case of
Zend_Test_PHPUnit, we have stub request and response objects that are
used as drop-in replacements for the standard versions -- and which
allow you to set the values for the various data sources.

> Otherwise, yeah, I am familiar w/ the request object from ZF, and all the
> ideas applied there and it's cool. Sometimes I wonder what PHP would look
> like if the superglobals are made read-only.

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend Framework           | http://framework.zend.com/

 « Return to Thread: $this->getRequest()->isPost() vs. ($_SERVER['REQUEST_METHOD'] == 'POST')