CakeRequest::here PHP Method

here() public method

Get the value of the current requests URL. Will include named parameters and querystring arguments.
public here ( boolean $base = true ) : string
$base boolean Include the base path, set to false to trim the base path off.
return string the current request URL including query string args.
    public function here($base = true)
    {
        $url = $this->here;
        if (!empty($this->query)) {
            $url .= '?' . http_build_query($this->query, null, '&');
        }
        if (!$base) {
            $url = preg_replace('/^' . preg_quote($this->base, '/') . '/', '', $url, 1);
        }
        return $url;
    }

Usage Example

 /**
  * @return array|bool
  */
 public function matchCurrentRoute()
 {
     $context = new RequestContext();
     $matcher = new UrlMatcher($this->routes, $context);
     $request = new CakeRequest();
     try {
         return $matcher->match($request->here());
     } catch (Exception $e) {
         //route is not registered in yml file
         return false;
     }
 }
All Usage Examples Of CakeRequest::here