0

enter image description here

There is error:

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

I try to composer update and comes out this error. why?

After try to run "composer dump-autoload", come out this error

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

Alijvhr
  • 1,695
  • 1
  • 3
  • 22
  • did you run `composer install` ? – Nehal Mar 11 '23 at 07:02
  • I did, after composer install it will advice me to composer update,then i follow instruction composer update still come out error. – Seewpeng Nea Mar 11 '23 at 07:07
  • Does this answer your question? [require(vendor/autoload.php): failed to open stream](https://stackoverflow.com/questions/41209349/requirevendor-autoload-php-failed-to-open-stream) – cengsemihsahin Mar 11 '23 at 07:20
  • Does this answer your question? [Fatal error: Class 'Illuminate\Foundation\Application' not found](https://stackoverflow.com/questions/29764368/fatal-error-class-illuminate-foundation-application-not-found) – Wahyu Kristianto Mar 11 '23 at 08:02

2 Answers2

0

Remove your compose.lock file.

Right-click on laragon icon in system tray and thick extensions:

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

enabling php extensions

Run cmd as administrator and then run these:

composer install --ignore-platform-reqs
composer dump-autoload
composer update --ignore-platform-reqs
Alijvhr
  • 1,695
  • 1
  • 3
  • 22
  • 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 – Seewpeng Nea Mar 11 '23 at 07:20
  • the first or second command thrown this? – Alijvhr Mar 11 '23 at 07:21
  • The second throw this – Seewpeng Nea Mar 11 '23 at 07:22
  • Can you add your composer.json content in your question? – Alijvhr Mar 11 '23 at 07:22
  • The error content in my question now. am i misunderstand your meaning? – Seewpeng Nea Mar 11 '23 at 07:27
  • I installed laragon. downloaded latest laravel from github! And an composer install [this image](https://freeimage.host/i/HX5zDIs) was the output as it should be! compose update runs ok! so there is a problem with your first command! we should find ansd solve that! – Alijvhr Mar 11 '23 at 07:35
  • Do you mean my first command is "composer install" that step ? – Seewpeng Nea Mar 11 '23 at 07:42
  • Yes, is your output same as my image? – Alijvhr Mar 11 '23 at 07:44
  • I got uploaded an error image, please refer it. – Seewpeng Nea Mar 11 '23 at 07:46
  • just remove your `compose.lock` file. – Alijvhr Mar 11 '23 at 08:00
  • I just deleted compose.lock file. there is another error "No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information." – Seewpeng Nea Mar 11 '23 at 08:08
  • this is not an error! its ok. now is the output of command `composer update` different? – Alijvhr Mar 11 '23 at 08:11
  • After run `composer install` there is having an error as image that i show you, then i run again `composer update` still the same result. – Seewpeng Nea Mar 11 '23 at 08:15
  • try `composer install --ignore-platform-reqs` and check the answer updated again! – Alijvhr Mar 11 '23 at 08:28
  • @SeewpengNea if my answer was helpful please accpet it, thanks. – Alijvhr Mar 11 '23 at 08:31
0

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

The issue is that you are not using proper naming convention for PSR-4.

Your file structure is app\Http\Controllers\Api\V1\TwoFactorApiController.php

Namespace should be App\Http\Controllers\Api\V1\TwoFactorApiController

Your current namespace is App\Http\Controllers\api\v1\TwoFactorApiController which is wrong.

Refactor the namespace and you won't see this message.

RAZIUL
  • 128
  • 2
  • 8