The main difference is that
$_GET['key'];
is a dependency on the environment. It requires the superglobal to be available and containing a key of that name. It's also just a simple array access, while
$this->getRequest()->getParam('key');
is an API method call. Access to the Request is abstracted. There is no dependency on the actual environment. The Request object could be a mock. The getParam
method will always return a value regardless whether it is from $_GET
or $_POST
.
Putting an abstraction on top of the Request is better, because it allows for more decoupling, less dependencies and therefor makes your application easier to test and maintain.