Lumen Framework中的“封闭”类在哪里?

时间:2019-12-06 10:12:50

标签: php laravel lumen

管腔内部的许多过程都使用“ closure”类。我知道闭包是什么,但我仍然想知道它在流明的外观。因此,我需要找到定义类的文件。

例如,我的authenticate.php中间件使用“关闭”,您可以在代码顶部看到它:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Factory as Auth;

class Authenticate
{
    /**
     * The authentication guard factory instance.
     *
     * @var \Illuminate\Contracts\Auth\Factory
     */
    protected $auth;

    /**
     * Create a new middleware instance.
     *
     * @param  \Illuminate\Contracts\Auth\Factory  $auth
     * @return void
     */
    public function __construct(Auth $auth)
    {
        $this->auth = $auth;
    }

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if ($this->auth->guard($guard)->guest()) {
            return response('Unauthorized.', 401);
        }

        return $next($request);
    }
}

但是与Lumen中的任何其他类不同,该类没有提供任何指向该类在源代码中位置的路径。我已经查找了根目录,但它不在那里。

那它在哪里?

1 个答案:

答案 0 :(得分:4)

您可以扫描PHP Closure Class中的文档。它是在PHP 5.3中添加的,不是在Lumen Framework或Laravel下使用PHP构建的。