簡體   English   中英

Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError(E_ERROR)類'APP \\ Mail \\ Reverify'未找到

[英]Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'APP\Mail\Reverify' not found

我在PHP Laravel 5中編寫了一個應用程序。我想在loginController中添加一個reverify函數,我在app / Mail中添加了一個Class Reverify Reverify.php,但是我收到了這個錯誤:

Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError(E_ERROR)找不到類'APP \\ Mail \\ Reverify'。

我做過工匠clear-compiledcomposer dump-autoload ,它composer dump-autoload 我在vendor / composer中檢查了我的autoload_classmap.php,我可以看到'App\\\\Mail\\\\Reverify' => $baseDir '/app/Mail/Reverify.php' ,在那里。

這是我的LoginController代碼。

<?php

namespace App\Http\Controllers\Auth;

use Mail;
use APP\Mail\Reverify;

class LoginController extends Controller  {

...

...

Mail::to($email)-> send(new Reverify($confirmation_code));

...
...}

我的Reverify.php在app / Mail中

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Reverify extends Mailable
{
    public $confirmation_code;

    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->confirmation_code = $confirmation_code; 
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('XXXX: lock out')->view('reverify');
    }
}

我的autoload_classmap.php在vendor / composer中

 'App\\Mail\\Reverify' => $baseDir . '/app/Mail/Reverify.php'

這是我的錯誤日志

2019-02-25 02:42:50] local.ERROR: Class 'APP\Mail\Reverify' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'APP\\Mail\\Reverify' not found at /home/vagrant/code/x/app/Http/Controllers/Auth/LoginController.php:207)

composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.1.3",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "5.5.*",
        "doctrine/dbal": "~2.5"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~7.0",
        "filp/whoops": "~2.1.10"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

LoginController中嘗試更改

use APP\\Mail\\Reverify use App\\Mail\\Reverify

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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