[英]Where is the implementation of '$app->run()' in Lumen?
它在Laravel\\Lumen\\Concerns\\RoutesRequests
。
如果您查看bootstrap/app.php
您会看到:
$app = new Laravel\Lumen\Application(
dirname(__DIR__)
);
所以我们知道$app
是Laravel\\Lumen\\Application
一个实例。
方法run()
没有在这个类上定义,但如果你仔细观察,你会看到:
class Application extends Container
{
use Concerns\RoutesRequests,
Concerns\RegistersExceptionHandlers;
这些特征为类定义了额外的行为。 具体来说,在Laravel\\Lumen\\Concerns\\RoutesRequests
你会发现:
/**
* Run the application and send the response.
*
* @param SymfonyRequest|null $request
* @return void
*/
public function run($request = null)
{
$response = $this->dispatch($request);
if ($response instanceof SymfonyResponse) {
$response->send();
} else {
echo (string) $response;
}
if (count($this->middleware) > 0) {
$this->callTerminableMiddleware($response);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.