If you’re working in a place other than a controller, view, helper, or component – such as an event listener, custom lib class, etc. – and need to access the CakeRequest object (which is available as $this->request in controllers/views/helpers), then use Router to get it:


$request = Router::getRequest();