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


PHP Request::getHost方法代码示例

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


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

示例1: buildBasicEntry

 /**
  * @param Request|\Symfony\Component\HttpFoundation\Request $request
  *
  * @return array
  */
 protected function buildBasicEntry($request)
 {
     return ['api_key' => $request->query->get('api_key', $request->headers->get(ManagedDefaults::DF_API_KEY)), 'content_type' => $request->getContentType(), 'content_length' => (int) $request->headers->get('Content-Length', 0), 'dfe' => [], 'host' => $request->getHost(), 'method' => $request->getMethod(), 'path_info' => $request->getPathInfo(), 'path_translated' => $request->server->get('PATH_TRANSLATED'), 'query' => $request->query->all() ?: [], 'request_timestamp' => (double) $request->server->get('REQUEST_TIME_FLOAT', microtime(true)), 'source_ip' => $request->getClientIps(), 'user_agent' => $request->headers->get('user-agent', 'None')];
 }
开发者ID:rajeshpillai,项目名称:df-managed,代码行数:9,代码来源:AuditingService.php

示例2: matches

 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route $route
  * @param  \Illuminate\Http\Request $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if (is_null($route->getCompiled()->getHostRegex())) {
         return true;
     }
     return preg_match($route->getCompiled()->getHostRegex(), $request->getHost());
 }
开发者ID:saj696,项目名称:pipe,代码行数:14,代码来源:HostValidator.php

示例3: map

 /**
  * Map the redirect routes.
  *
  * @param UrlGenerator                $url
  * @param Router                      $router
  * @param Request                     $request
  * @param RedirectRepositoryInterface $redirects
  * @internal param Filesystem $files
  * @internal param Application $application
  */
 public function map(UrlGenerator $url, Router $router, Request $request, RedirectRepositoryInterface $redirects)
 {
     if ($request->segment(1) == 'admin') {
         return;
     }
     /* @var RedirectInterface $redirect */
     foreach ($redirects->sorted() as $redirect) {
         if (!starts_with($parsed = $redirect->getFrom(), ['http://', 'https://', '//'])) {
             $parsed = $url->to($redirect->getFrom());
         }
         $parsed = parse_url(preg_replace_callback("/\\{[a-z]+\\?\\}/", function ($matches) {
             return str_replace('?', '!', $matches[0]);
         }, $parsed));
         if (isset($parsed['host']) && $parsed['host'] == $request->getHost()) {
             /**
              * Route a domain redirect in a domain group.
              */
             $router->group(['domain' => $parsed['host']], function () use($parsed, $router, $redirect) {
                 $path = ltrim(preg_replace_callback("/\\{[a-z]+\\!\\}/", function ($matches) {
                     return str_replace('!', '?', $matches[0]);
                 }, $parsed['path']), '/');
                 $router->any($path ?: '/', ['uses' => 'Anomaly\\RedirectsModule\\Http\\Controller\\RedirectsController@handle', 'redirect' => $redirect->getId()])->where(['any' => '(.*)', 'path' => '(.*)']);
             });
         } else {
             /**
              * Route a standard redirect.
              */
             $router->any($redirect->getFrom(), ['uses' => 'Anomaly\\RedirectsModule\\Http\\Controller\\RedirectsController@handle', 'redirect' => $redirect->getId()])->where(['any' => '(.*)', 'path' => '(.*)']);
         }
     }
 }
开发者ID:visualturk,项目名称:redirects-module,代码行数:41,代码来源:RedirectsModuleServiceProvider.php

示例4: matches

 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if (is_null($route->hostExpression())) {
         return true;
     }
     return preg_match($route->hostExpression(), $request->getHost());
 }
开发者ID:allapo,项目名称:to-do-list,代码行数:14,代码来源:HostValidator.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $host = $request->getHost();
     $site = Site::setSiteByHost($host);
     $response = $next($request);
     return $response;
 }
开发者ID:klsandbox,项目名称:sitemodel,代码行数:15,代码来源:SetSite.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->ajax()) {
         $subdomain = $this->getSubdomain($request->getHost());
         //return redirect()->guest('auth/login');
     }
     return $next($request);
 }
开发者ID:torann,项目名称:device-view,代码行数:16,代码来源:SubdomainRedirect.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $config = app('config');
     $is_student_site = $request->getHost() == $config->get('site.students_domain');
     $site = $is_student_site ? $config->get('site-students') : $config->get('site-faithpromise');
     $config->set('site', array_merge($config['site'], $site));
     return $next($request);
 }
开发者ID:mcculley1108,项目名称:faithpromise.org,代码行数:15,代码来源:SiteConfig.php

示例8: findRoute

 protected function findRoute(Request $request, array $routes)
 {
     foreach ($routes as $key => $route) {
         list($method, $domain, $uri) = explode(' ', $key);
         if ($request->getMethod() == $method && $request->getHost() == $domain && trim($request->getPathInfo(), '/') === trim($route['uri'], '/')) {
             return $route;
         }
     }
 }
开发者ID:leloulight,项目名称:laravel_latest,代码行数:9,代码来源:RoutingAdapterStub.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $host = $request->getHost();
     $parts = explode('.', $host);
     /*if (count($parts) > 2) {
           show_404();
       }*/
     return $next($request);
 }
开发者ID:KritaMaharjan,项目名称:expert,代码行数:16,代码来源:PreventSystemAccess.php

示例10: setRequest

 /**
  * Check the request for the current domain
  *
  * @param Request $request The request object
  */
 public static function setRequest(Request $request)
 {
     $host = strtolower(preg_replace('/^(.*(\\.|\\/))?([^\\.]+\\.[^\\.]+)$/i', '$3', $request->getHost()));
     $sites = Config::get('app.sites');
     $name = Config::get('app.fallback_site');
     foreach ($sites as $site => $settings) {
         $name = in_array($host, $settings['domains']) ? $site : $name;
     }
     static::$name = $name;
 }
开发者ID:AccessibilityNL,项目名称:User-Testing-Tool,代码行数:15,代码来源:Site.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $handledDomains = config('app.domains');
     $currentDomain = $request->getHost();
     foreach ($handledDomains as $locale => $domain) {
         if (preg_match('#' . preg_quote($domain, '#') . '$#', $currentDomain)) {
             $this->app->setLocale($locale);
         }
     }
     return $next($request);
 }
开发者ID:Korko,项目名称:SecretSanta,代码行数:19,代码来源:Language.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!$request->ajax()) {
         $visit = new Visit();
         $visit->page = parse_url($request->fullUrl(), PHP_URL_PATH);
         $visit->ip = $request->ip();
         $visit->host = $request->getHost();
         $visit->user_agent = Agent::browser() . ' ' . Agent::version(Agent::browser());
         $visit->save();
     }
     return $next($request);
 }
开发者ID:Nadiyka,项目名称:labweb,代码行数:19,代码来源:VisitorsMiddleware.php

示例13: shouldIndex

 protected function shouldIndex(Request $request) : bool
 {
     if (ends_with($request->getHost(), 'spatie.be')) {
         return false;
     }
     if (!app()->environment('production')) {
         return false;
     }
     if (!env('ALLOW_ROBOTS')) {
         return false;
     }
     return request()->isFront();
 }
开发者ID:spatie-custom,项目名称:blender,代码行数:13,代码来源:RobotsMiddleware.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     $config = app('config');
     $view = app('view');
     $domain = str_replace($config->get('tenancy.multi_site.ignorable_domain_components', []), '', $request->getHost());
     $tenant = $this->repository->findOneByDomain($domain);
     if (!$tenant instanceof TenantParticipant) {
         throw new \RuntimeException(sprintf('Unable to resolve host "%s" to valid TenantParticipant.', $domain));
     }
     $finder = $view->getFinder();
     if ($finder instanceof TenantViewFinder) {
         $paths = $this->appendPathsInFinder($finder, $tenant);
     } else {
         $paths = $this->registerPathsInFinder($view, $finder, $tenant);
     }
     // update app config
     $config->set('app.url', $request->getHost());
     $config->set('view.paths', array_merge($config->get('view.paths', []), $paths));
     // bind resolved tenant data to container
     app('auth.tenant')->updateTenancy(new NullUser(), $tenant->getTenantOwner(), $tenant);
     return $next($request);
 }
开发者ID:illuminate3,项目名称:laravel-doctrine-tenancy,代码行数:30,代码来源:TenantSiteResolver.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->is('admin*') || $request->is('auth*')) {
         $admin_domain = \Config::get('app.admin_domain');
         if ($request->getHost() == $admin_domain) {
             return $next($request);
         }
         abort(403, 'Invalid admin domain');
     }
     $domain = app('domain');
     if (!is_object($domain)) {
         abort(403, 'Invalid domain');
         return false;
     }
     return $next($request);
 }
开发者ID:evendev,项目名称:peak,代码行数:23,代码来源:VerifiesDomain.php


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