Since the version 2.x of CakePHP has a requests and response objects, they are provided an abstraction around HTTP Requests and responses.
If you are not familiar with CakePHP, it’s a common step when you bake and use
$this->request->data instead of $_POST.
Most of the time, we need to modify and append values on our Request data. This can be an identifier of logged user or values for any fields. In many situations, implementations will like this:
Data can be modified easily - you just need to call withData or withParsedBody method and after set the Request (you can also modify the query calling withQueryParams):
Both implementations will generate the same value, but if you have a keen eye, you will see that the second implementation is more clear. Also, our Request has these values on data.
This information can be useful when you use Components from Plugins, as they will expect the values on Requests.
That’s all bakers! I hope this content is useful for you and will improve your requests!