出现错误:
Warning: require(C:\laragon\www\sprii\public/../vendor/autoload.php): Failed to open stream: No such file or directory in C:\laragon\www\sprii\public\index.php on line 34
Fatal error: Uncaught Error: Failed opening required 'C:\laragon\www\sprii\public/../vendor/autoload.php' (include_path='.;C:/laragon/etc/php/pear') in C:\laragon\www\sprii\public\index.php:34 Stack trace: #0 {main} thrown in C:\laragon\www\sprii\public\index.php on line 34
我尝试composer update
,但出现此错误。为什么?
尝试运行“composer dump-autoload”后,出现此错误
Generating optimized autoload files
Class App\Http\Controllers\api\v1\TwoFactorApiController located in C:/laragon/www/sprii/app\Http\Controllers\Api\V1\TwoFactorApiController.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script
> @php artisan package:discover --ansi
Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\laragon\www\sprii\bootstrap\app.php:14
Stack trace:
#0 C:\laragon\www\sprii\artisan(20): require_once()
#1 {main}
thrown in C:\laragon\www\sprii\bootstrap\app.php on line 14
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
2条答案
按热度按时间svmlkihl1#
删除
compose.lock
文件。右键单击系统托盘中的laragon图标和厚扩展:
以管理员身份运行
cmd
,然后运行以下命令:7nbnzgx92#
正在生成优化的自动加载文件位于C:/laragon/www/sprii/app\Http\Controllers\Api\V1\TwoFactorApiController.php中的类App\Http\Controllers\api\v1\TwoFactorApiController.php不符合psr-4自动加载标准。正在跳过。类Illuminate\Foundation\ComposerScripts不可自动加载,无法调用自动加载后转储脚本
问题是您没有为PSR-4使用正确的命名约定。
您的文件结构为
app\Http\Controllers\Api\V1\TwoFactorApiController.php
命名空间应为
App\Http\Controllers\Api\V1\TwoFactorApiController
当前命名空间是
App\Http\Controllers\api\v1\TwoFactorApiController
,这是错误的。重构名称空间,您将不会看到此消息。