gpt4 book ai didi

php - 如何修复 Laravel 5.7 中的 "Class signed does not exist"错误?

转载 作者:可可西里 更新时间:2023-11-01 13:39:46 24 4
gpt4 key购买 nike

我刚刚将我的 Laravel 项目从 5.6 更新到 5.7。我升级的主要原因是我需要将电子邮件验证添加到我的项目中。在我完成所有升级步骤并根据 Laravel 文档实现电子邮件验证后,我收到了一个错误。所以导致错误的步骤是这样的:

我使用 1 条路线进行测试,在我的 ..\routes\web.php 文件中我有这行代码:

Route::get('dashboard', ['uses' => 'DashboardController@getDashboard'])->middleware('verified');

当我尝试去那条路线时,它确实将我重定向到 ..\views\auth\verify.blade.php 的 View ,因为它应该。在那里,我单击链接以发送验证电子邮件。我收到电子邮件,然后单击电子邮件中的按钮以验证我的电子邮件。它会启动一个浏览器并开始将我导航到某个地方,这就是它遇到错误的时候:

Class signed does not exist

经过大量研究后,我发现错误出在说明要创建的新 VerificationController.php 文件中,导致问题的代码行是:

$this->middleware('signed')->only('verify');

如果我注释掉这一行并再次单击我电子邮件中的按钮,那么它可以正常工作,并且我的用户 email_verified_at 列会更新为日期时间戳。

下面是整个 VerificationController.pas,以防它阐明问题:

<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;

class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/dashboard';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

最佳答案

看看 Laravel Documentation on Signed URLs

我猜你在 $routeMiddleware 数组中遗漏了这个条目

// In app\Http\Kernel.php
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
...
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
];

关于php - 如何修复 Laravel 5.7 中的 "Class signed does not exist"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52407547/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com