public function getHostInfo()
{
if ($this->_hostInfo === null) {
$request = Yii::$app->getRequest();
if ($request instanceof \yii\web\Request) {
$this->_hostInfo = $request->getHostInfo();
} else {
throw new InvalidConfigException('Please configure UrlManager::hostInfo correctly as you are running a console application.');
}
}
return $this->_hostInfo;
}