framework/web/UrlManager.php
public function getScriptUrl()
    {
        if ($this->_scriptUrl === null) {
            $request = Yii::$app->getRequest();
            if ($request instanceof Request) {
                $this->_scriptUrl = $request->getScriptUrl();
            } else {
                throw new InvalidConfigException('Please configure UrlManager::scriptUrl correctly as you are running a console application.');
            }
        }

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

        return $this->_scriptUrl;
    }
Returns the entry script URL that is used by [[createUrl()]] to prepend to created URLs.
It defaults to [[Request::scriptUrl]].
This is mainly used when [[enablePrettyUrl]] is `false` or [[showScriptName]] is `true`.
@return string the entry script URL that is used by [[createUrl()]] to prepend to created URLs.
@throws InvalidConfigException if running in console application and [[scriptUrl]] is not configured.