本文整理汇总了PHP中Illuminate\Container\Container::boot方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::boot方法的具体用法?PHP Container::boot怎么用?PHP Container::boot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Container\Container
的用法示例。
在下文中一共展示了Container::boot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle a given request and return the response.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
// Our middleware needs to ensure that Laravel is booted before we
// can do anything. This gives us access to all the booted
// service providers and other container bindings.
$this->container->boot();
if ($request instanceof InternalRequest || $this->auth->user()) {
return $this->app->handle($request, $type, $catch);
}
// If a collection exists for the request and we can match a route
// from the request then we'll check to see if the route is
// protected and, if it is, we'll attempt to authenticate.
if ($this->router->requestTargettingApi($request) && ($collection = $this->getApiRouteCollection($request))) {
try {
$route = $this->controllerReviser->revise($collection->match($request));
if ($this->routeIsProtected($route)) {
return $this->authenticate($request, $route) ?: $this->app->handle($request, $type, $catch);
}
} catch (HttpExceptionInterface $exception) {
// If we catch an HTTP exception then we'll simply let
// the wrapping kernel do its thing.
}
}
return $this->app->handle($request, $type, $catch);
}
示例2: handle
/**
* Handle a given request and return the response.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$this->container->boot();
$this->prepareConfig($request);
// Internal requests as well as requests that are not targetting the
// API will not be rate limited. We'll also be sure not to perform
// any rate limiting if it has been disabled.
if ($request instanceof InternalRequest or !$this->router->requestTargettingApi($request) or $this->rateLimitingDisabled()) {
return $this->app->handle($request, $type, $catch);
}
$this->cache->add($this->config['keys']['requests'], 0, $this->config['reset']);
$this->cache->add($this->config['keys']['reset'], time() + $this->config['reset'] * 60, $this->config['reset']);
$this->cache->increment($this->config['keys']['requests']);
if ($this->exceededRateLimit()) {
list($version, $format) = $this->router->parseAcceptHeader($request);
$response = (new Response(['message' => $this->config['exceeded']], 403))->morph($format);
} else {
$response = $this->app->handle($request, $type, $catch);
}
return $this->adjustResponseHeaders($response);
}