首页 > 其他分享 >laravel: 报错:Uncaught ReflectionException: Class "view" does not exist

laravel: 报错:Uncaught ReflectionException: Class "view" does not exist

时间:2024-09-25 18:24:44浏览次数:1  
标签:laravel web Container ReflectionException api 报错 php

一,报错信息:

Uncaught ReflectionException: Class "view" does not exist in /web/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:938
Stack trace:
#0 /web/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(938): ReflectionClass->__construct()
#1 /web/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(815): Illuminate\Container\Container->build()
#2 /web/api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1046): Illuminate\Container\Container->resolve() 
...

情况说明:
这些代码在测试站没有问题,新复制到了正式站目录后报错,

二,解决:

1,网上的解决办法:
看网上的文档是执行两个命令,但在我这里未生效:
第一个命令: php artisan package:discover,报错了

[root@web api]# php artisan package:discover

In ClassLoader.php line 576:

  include(/web/api/vendor/composer/../laravel/ui/src/UiServiceProvider.php): Failed to open stream: No such file or directory  

第二个命令: 报错与上一个相同

[root@web api]# php artisan key:generate

In ClassLoader.php line 576:

  include(/web/api/vendor/composer/../laravel/ui/src/UiServiceProvider.php): Failed to open stream: No such file or directory  

 查看报错信息,是缺少/vendor/composer/laravel/ui目录下的代码文件
2,网上的问题和我情况不同,
我的解决:
我这儿有/vendor/composer/laravel/ui目录,但目录下是空的,没有代码文件,
查看composer:

[lhd@web api]$ composer show -i | grep ui
You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages.
fruitcake/php-cors                         1.3.0   Cross-origin resource sharing library for the Symfony HttpFoundation
laravel/ui                                 4.5.2   Laravel UI utilities and presets.
ramsey/uuid                                4.7.6   A PHP library for generating and working with universally unique identifiers (UUIDs).
symfony/finder                             7.1.1   Finds files and directories via an intuitive fluent interface
symfony/polyfill-uuid                      1.30.0  Symfony polyfill for uuid functions
symfony/uid                                7.1.1   Provides an object-oriented API to generate and represent UIDs

因为composer认为安装了这个库,但不清楚为什么这个库下面没有代码,所以引发了报错
3,最终解决:

 composer remove laravel/ui

之后恢复正常,
这个库安装后同步到线上时代码被git忽略,
所以会报缺少文件错误,
去掉此库或重新安装后再push代码也行

标签:laravel,web,Container,ReflectionException,api,报错,php
From: https://www.cnblogs.com/architectforest/p/18431654

相关文章