Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "Class signed does not exist" error in Laravel 5.7?

I just updated my Laravel project from 5.6 to 5.7. The primary reason I upgraded was I needed to add Email Verification to my project. After I completed all upgrade steps and implemented the Email Verification as per the Laravel documentation I am getting an error. So the steps leading up to the error is this:

I used 1 route to test with, in my ..\routes\web.php file I have this line of code:

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

When I try to go to that route it does redirect me to the view for ..\views\auth\verify.blade.php as it should. There I click the link to send the verification email. I get the email then I click the button in the email to verify my email. It launches a browser and starts to navigate me somewhere and thats when it gets an error:

Class signed does not exist

After much research I discovered the error was in the new VerificationController.php file that the instructions said to create and the line of code causing the problem is:

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

If I comment this line out and click the button in my email again then it works without any errors and my users email_verified_at column is updated with a datetime stamp.

Below is the entire VerificationController.pas in case it sheds any light on the problem:

<?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');
    }
}
like image 684
Wayne Fulcher Avatar asked Sep 19 '18 13:09

Wayne Fulcher


People also ask

How to fix bindingresolutionexception target class[] does not exist in Laravel?

Illuminate\Contracts\Container\BindingResolutionException Target class [] does not exist. Illuminate\Container\Container::build vendor/laravel/framework/src/Illuminate/Container/Container.php:807 Open your favorite command-line tools and go to the root path of your laravel code and type this code. Then try to refresh your page.

Why is my Laravel database not connecting to the server?

It happens mainly due to incorrect database details in Laravel database configuration file, bad user privileges, etc. At Bobcares, we often get requests from our customers to fix Laravel database connection error as part of our Server Management Services. Today, in this article we’ll see how our Support Engineers fix this database connection error.

How to fix Laravel error 9 0?

If you guys getting this error while updating to laravel 9.0 then remove below line of code from composer.json Then, change the use Fideloper\Proxy\TrustProxies as Middleware; to use Illuminate\Http\Middleware\TrustProxies as Middleware; in a file app\Http\Middleware\TrustProxies.php file

Why are so many Laravel tutorials broken?

The is s ue is not that the code is broken, but that 99.9% of Laravel tutorials are now broken in this department because most of them relied on this default namespace for the string syntax. Up until Laravel 7, the RouteServiceProvider.php file had the following code:


1 Answers

Take a look at the Laravel Documentation on Signed URLs

My guess is you are missing this entry in the $routeMiddleware array

// 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,
];
like image 81
Luke Ramsden Avatar answered Oct 02 '22 05:10

Luke Ramsden