【问题标题】:Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'APP\Mail\Reverify' not foundSymfony \ Component \ Debug \ Exception \ FatalThrowableError(E_ERROR)类'APP \ Mail \ Reverify'未找到
【发布时间】:2019-07-18 10:11:05
【问题描述】:

我正在用 PHP Laravel 5 编写一个应用程序。我想在 loginController 中添加一个 reverify 函数,我在 app/Mail 中添加了一个 Class Reverify Reverify.php,但是我收到了这个错误:

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

我已经完成了工匠clear-compiled 和composer dump-autoload,它没有工作。我在供应商/作曲家中检查了我的 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 在供应商/作曲家中

 '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
    }
}

【问题讨论】:

  • 命名空间应该是APP还是App?
  • @MattKomarnicki 谢谢马特!我太傻了....

标签: php laravel


【解决方案1】:

在 LoginController 中尝试更改

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-02
    • 2020-05-15
    • 2017-08-21
    相关资源
    最近更新 更多