我有一个 Laravel 项目,但是当我运行
php artisan route:list
时出现此错误:
ReflectionException
Class "CuboController" does not exist
at C:\Users\ricar\dev\SistemaCubosLS\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteListCommand.php:234
230▕ if ($this->isFrameworkController($route)) {
231▕ return false;
232▕ }
233▕
➜ 234▕ $path = (new ReflectionClass($route->getControllerClass()))
235▕ ->getFileName();
236▕ } else {
237▕ return false;
238▕ }
1 C:\Users\ricar\dev\SistemaCubosLS\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteListCommand.php:234
ReflectionClass::__construct()
2 C:\Users\ricar\dev\SistemaCubosLS\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteListCommand.php:156
Illuminate\Foundation\Console\RouteListCommand::isVendorRoute()
奇怪的是,当我用
php artisan serve
启动服务器时,它在我的机器上运行得很好,但是当我尝试访问 ubuntu 服务器时不让我进入,抛出 404 错误。
控制器存在,就像我说的,在本地工作完美,但在 apache 服务器中抛出 404 错误。
这可能是什么以及如何修复它?
不要忘记在你的路线中使用它
use App\Http\Controllers\CuboController;
如果显示 404,请尝试检查
php artisan route:list
。如果没有显示,请尝试php artisan optimize
先生。 Kenneth 在评论部分为您解释了很多。