【问题标题】:Where is "Closure" class located inside Lumen Framework?Lumen 框架内的“闭包”类在哪里?
【发布时间】:2020-03-31 07:46:44
【问题描述】:

lumen 内部的许多进程都使用“闭包”类。我知道闭包是什么,但我仍然想知道它在 Lumen 中的样子。因此,我需要找到定义类的文件。

比如我的authenticate.php中间件使用了“Closure”,你可以在代码顶部看到:

<?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 中的任何其他类不同,该类不提供任何指向源代码中类的位置的路径。我查了根目录,没有。

那么它在哪里?

【问题讨论】:

标签: php laravel lumen


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 2021-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-26
    • 2017-04-30
    相关资源
    最近更新 更多