当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getBaseUrl方法代码示例

本文整理汇总了PHP中yii\web\Request::getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBaseUrl方法的具体用法?PHP Request::getBaseUrl怎么用?PHP Request::getBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\web\Request的用法示例。


在下文中一共展示了Request::getBaseUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleRedirectRequest

 /**
  * @param \yii\web\Request $request
  * @return \yii\web\Response|null
  */
 protected function handleRedirectRequest($request)
 {
     $key = ltrim(str_replace($request->getBaseUrl(), '', $request->getUrl()), '/');
     if (array_key_exists($key, $this->redirectRoutes)) {
         return $this->getResponse()->redirect(Url::to($this->redirectRoutes[$key]));
     } else {
         return null;
     }
 }
开发者ID:rekurzia,项目名称:yii2-redirect,代码行数:13,代码来源:Application.php

示例2: redirectToLanguage

 /**
  * Redirect to the current URL with given language code applied
  *
  * @param string $language the language code to add. Can also be empty to not add any language code.
  */
 protected function redirectToLanguage($language)
 {
     // Examples:
     // 1) /baseurl/index.php/some/page?q=foo
     // 2) /baseurl/some/page?q=foo
     // 3)
     // 4) /some/page?q=foo
     if ($this->showScriptName) {
         // 1) /baseurl/index.php
         // 2) /baseurl/index.php
         // 3) /index.php
         // 4) /index.php
         $redirectUrl = $this->_request->getScriptUrl();
     } else {
         // 1) /baseurl
         // 2) /baseurl
         // 3)
         // 4)
         $redirectUrl = $this->_request->getBaseUrl();
     }
     if ($language) {
         $redirectUrl .= '/' . $language;
     }
     // 1) some/page
     // 2) some/page
     // 3)
     // 4) some/page
     $pathInfo = $this->_request->getPathInfo();
     if ($pathInfo) {
         $redirectUrl .= '/' . $pathInfo;
     }
     if ($redirectUrl === '') {
         $redirectUrl = '/';
     }
     // 1) q=foo
     // 2) q=foo
     // 3)
     // 4) q=foo
     $queryString = $this->_request->getQueryString();
     if ($queryString) {
         $redirectUrl .= '?' . $queryString;
     }
     Yii::$app->getResponse()->redirect($redirectUrl);
     if (YII_ENV_TEST) {
         throw new \yii\base\Exception(\yii\helpers\Url::to($redirectUrl));
     } else {
         Yii::$app->end();
     }
 }
开发者ID:JQL,项目名称:Yii2_Basic_Configuration,代码行数:54,代码来源:UrlManager.php

示例3: getBaseUrl

 public function getBaseUrl()
 {
     return str_replace($this->web, "", parent::getBaseUrl()) . $this->adminUrl;
 }
开发者ID:CGTAdal,项目名称:yii2demoapp,代码行数:4,代码来源:Request.php

示例4: Request

<?php

use yii\web\Request;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
// Replace url
$request = new Request();
$baseUrlFront = str_replace('/admin', '', $request->getBaseUrl());
$scriptUrlFront = str_replace('/admin', '', $request->getScriptUrl());
return ['id' => 'app-backend', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\\controllers', 'bootstrap' => ['log', 'common\\components\\BackendBootstrap'], 'modules' => [], 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'i18n' => ['translations' => ['writesdown' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@app/messages', 'sourceLanguage' => 'en', 'fileMap' => []]]], 'urlManagerFront' => ['class' => 'yii\\web\\urlManager', 'scriptUrl' => $scriptUrlFront, 'baseUrl' => $baseUrlFront], 'urlManagerBack' => ['class' => 'yii\\web\\urlManager'], 'authManager' => ['class' => 'yii\\rbac\\DbManager']], 'params' => $params];
开发者ID:ochiem,项目名称:app-cms,代码行数:9,代码来源:main.php

示例5: Request

<?php

use yii\web\Request;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
// Replace url
$request = new Request();
$baseUrlBack = str_replace('/frontend/web', '/backend/web', $request->getBaseUrl());
$scriptUrlBack = str_replace('/frontend/web', '/backend/web', $request->getScriptUrl());
return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\\controllers', 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'i18n' => ['translations' => ['writesdown' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@app/messages', 'sourceLanguage' => 'en', 'fileMap' => []]]], 'urlManagerFront' => ['class' => 'yii\\web\\urlManager'], 'urlManagerBack' => ['class' => 'yii\\web\\urlManager', 'scriptUrl' => $scriptUrlBack, 'baseUrl' => $baseUrlBack], 'authManager' => ['class' => 'yii\\rbac\\DbManager']], 'params' => $params];
开发者ID:wozhen,项目名称:yii2-cms-writedown,代码行数:9,代码来源:main.php

示例6: Request

<?php

use yii\web\Request;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
// Replace url
$request = new Request();
$baseUrlBack = $request->getBaseUrl() . '/admin';
$scriptUrlBack = str_replace('/index.php', '/admin/index.php', $request->getScriptUrl());
return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'common\\components\\FrontendBootstrap'], 'controllerNamespace' => 'frontend\\controllers', 'modules' => [], 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'i18n' => ['translations' => ['writesdown' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@app/messages', 'sourceLanguage' => 'en', 'fileMap' => []]]], 'urlManagerFront' => ['class' => 'yii\\web\\urlManager'], 'urlManagerBack' => ['class' => 'yii\\web\\urlManager', 'scriptUrl' => $scriptUrlBack, 'baseUrl' => $baseUrlBack], 'authManager' => ['class' => 'yii\\rbac\\DbManager'], 'view' => ['theme' => []]], 'params' => $params];
开发者ID:ochiem,项目名称:app-cms,代码行数:9,代码来源:main.php


注:本文中的yii\web\Request::getBaseUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。