本文整理汇总了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')];
}
示例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());
}
示例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' => '(.*)']);
}
}
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}