简体   繁体   English

Lumen 中 '$app->run()' 的实现在哪里?

[英]Where is the implementation of '$app->run()' in Lumen?

I can't find where the implementation of run() method that is used on Lumen is defined.我找不到 Lumen 上使用的run()方法的实现在哪里定义。 The one that can be seen in the bootstrapping file :可以在引导文件中看到的那个

$app->run();

Where is this method defined?这个方法在哪里定义?

It is defined on Laravel\\Lumen\\Concerns\\RoutesRequests .它在Laravel\\Lumen\\Concerns\\RoutesRequests

If you take a look at bootstrap/app.php you'll see this:如果您查看bootstrap/app.php您会看到:

$app = new Laravel\Lumen\Application(
    dirname(__DIR__)
);

So we know that $app is an instance of Laravel\\Lumen\\Application .所以我们知道$appLaravel\\Lumen\\Application一个实例。

The method run() is not defined on this class, but if you look closely, you'll see this:方法run()没有在这个类上定义,但如果你仔细观察,你会看到:

class Application extends Container
{
    use Concerns\RoutesRequests,
        Concerns\RegistersExceptionHandlers;

Those traits define additional behaviour for the class .这些特征为类定义了额外的行为 Specifically, on Laravel\\Lumen\\Concerns\\RoutesRequests you'll find:具体来说,在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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM