It is often useful to wrap commonly-used features like this -- for example, so 
you can easily test code using mock objects. The defaulting feature is a useful 
bonus, too, as you observe. This all goes with the framework's overall 
dependency-injection philosophy -- rather than accessing $_GET (which is a 
global variable, which allows the code to magically pull values out of the 
air), wrapping $_GET in the request object provides a more clearly-defined (and 
easily overrideable) origin for the data.

- Demian

> -----Original Message-----
> From: dennis-fedco [mailto:[email protected]]
> Sent: Thursday, June 12, 2014 10:07 AM
> To: [email protected]
> Subject: [fw-general] on getQuery()
> 
> What is the rationale behind using $request->getQuery() vs using $_GET
> directly?
> 
> is getQuery() there to provide an Object Oriented way of accessing $_GET, or
> is there more to it?
> 
> Because from initial testing ... I do not see much different except the
> syntax.
> And the ability to use default value, i.e getQuery('var', 'default');
> 
> 
> 
> --
> View this message in context: http://zend-framework-
> community.634137.n4.nabble.com/on-getQuery-tp4662135.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 
> --
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
> 


--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to