如何在windows下使用laragon设置laravel

8dtrkrch  于 2023-03-13  发布在  Windows
关注(0)|答案(2)|浏览(142)

出现错误:

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
svmlkihl

svmlkihl1#

删除compose.lock文件。
右键单击系统托盘中的laragon图标和厚扩展:

Laragon->PHP->Extensions->Sodium & pdo_sqlite

以管理员身份运行cmd,然后运行以下命令:

composer install --ignore-platform-reqs
composer dump-autoload
composer update --ignore-platform-reqs
7nbnzgx9

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,这是错误的。
重构名称空间,您将不会看到此消息。

相关问题