簡體   English   中英

Lumen 中 '$app->run()' 的實現在哪里?

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

我找不到 Lumen 上使用的run()方法的實現在哪里定義。 可以在引導文件中看到的那個

$app->run();

這個方法在哪里定義?

它在Laravel\\Lumen\\Concerns\\RoutesRequests

如果您查看bootstrap/app.php您會看到:

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

所以我們知道$appLaravel\\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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM