【问题标题】:Laravel ReflectionException : Class CustomerAccountController does not existLaravel ReflectionException:类 CustomerAccountController 不存在
【发布时间】:2022-10-25 01:07:41
【问题描述】:

我在 Laravel 5.7 和 Voyager 上有这个项目在 WAMP 上有 2 个问题,第一个是当我运行 php artisan route:list 时,结果是:

 ReflectionException  : Class CustomerAccountController does not exist
 at C:\wamp64\www\cell_marketplace\vendor\laravel\framework\src\Illuminate\Container\Container.php:779

实际上该类存在,我在另一个进程上使用它的函数并且它正在工作,我检查了命名空间,运行composer dump-autoload 没有结果。

第二个,我在 Voyager 上创建了一个 BREAD,我得到了模型类和控制器类,但是当我再次访问该资源的索引时,得到了这个:

 ReflectionException: Class DropOffController does not exist in \vendor\laravel\framework\src\Illuminate\Container\Container.php:779

并且控制器存在并且具有它实际工作的功能,所以我认为这与第一个有关,但如果有人可以提供帮助,我将非常感激

CustomerAccountController 类:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Voyager\VoyagerBaseController;
use App\Models\CustomerAccount;
use App\Models\CustomerAccountTransaction;
use App\Models\Provider;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
use Stripe\Charge;
use Stripe\Stripe;
use TCG\Voyager\Facades\Voyager;

class CustomerAccountController extends VoyagerBaseController
{
[...]

【问题讨论】:

  • 检查其他一些事情,因为 composer dump-autoload 似乎没有帮助:类拼写、大写(区分大小写,取决于操作系统)、命名空间使用(在文件中定义并具有正确的路径)或文件/文件夹权限( s) ...也许可以试试php artisan config:clearphp artisan cache:clear 看看这些是否有帮助。如果一切看起来都不错,请尝试对您的文件进行 lint 检查,以确保类 php -l file.php 没有语法错误。
  • 感谢您的回答!。我已经尝试清除配置缓存和应用程序缓存,没有任何变化,检查命名空间,类拼写但我找不到任何错字。此外,如果类上出现任何错误,则其余方法将无法执行并且它们会执行,知道吗?
  • 你检查过文件上的php -l 吗? ... another 5.7 user 在导致该错误的函数之一中缺少 ;。您也可以尝试php artisan route:clear,但除此之外,将类定义附加到问题中。
  • 是的,我做到了,我得到了No syntax errors detected in CustomerAccountController.phpNo syntax errors detected in DropOffController.php,当我执行route:clear 它实际上清除了路由缓存,但错误仍然存​​在

标签: php laravel laravel-5 wamp


【解决方案1】:

我发现了问题,它需要控制器的绝对路径,而不是为该资源配置 BREAD 时的相对路径,该项目位于 Laravel Voyager 中。

【讨论】:

    猜你喜欢
    • 2015-12-05
    • 2014-01-24
    • 1970-01-01
    • 2017-04-03
    • 2019-11-14
    • 2021-05-31
    • 2020-03-17
    • 2016-02-28
    • 1970-01-01
    相关资源
    最近更新 更多