Symfony\Component\HttpFoundation\Request::getHttpHost PHP Method

getHttpHost() public method

The port name will be appended to the host if it's non-standard.
public getHttpHost ( ) : string
return string
    public function getHttpHost()
    {
        $scheme = $this->getScheme();
        $port = $this->getPort();

        if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
            return $this->getHost();
        }

        return $this->getHost().':'.$port;
    }

Usage Example

Example #1
0
 /**
  *
  * @param Request $request
  * @throws AppException
  * @return ApplicationUri
  */
 public function match($request)
 {
     $found = null;
     $uris = ApplicationUriQuery::create()->joinApplication()->filterByHttphost($request->getHttpHost())->find();
     $requestUri = Text::create($request->getRequestUri())->trimRight('/');
     foreach ($uris as $uri) {
         $basepath = new Text($uri->getBasepath());
         // either request uri and uri basepath are both empty
         // or request uri starts with basepath
         if ($basepath->isEmpty() && $uri->getHttphost() == $request->getHttpHost() || $requestUri->startsWith($basepath)) {
             // assign when it's the first found
             if ($found === null) {
                 $found = $uri;
             } else {
                 if ($basepath->count('/') > Text::create($found->getBasepath())->count('/')) {
                     $found = $uri;
                 }
             }
         }
     }
     if ($found === null) {
         throw new AppException(sprintf('No app found on %s', $request->getUri()), 404);
     }
     $this->destination = str_replace($found->getBasepath(), '', $request->getRequestUri());
     return $found;
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::getHttpHost