There is error:
Warning: require(C:laragonwwwspriipublic/../vendor/autoload.php): Failed to open stream: No such file or directory in C:laragonwwwspriipublicindex.php on line 34
Fatal error: Uncaught Error: Failed opening required 'C:laragonwwwspriipublic/../vendor/autoload.php' (include_path='.;C:/laragon/etc/php/pear') in C:laragonwwwspriipublicindex.php:34 Stack trace: #0 {main} thrown in C:laragonwwwspriipublicindex.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 AppHttpControllersapiv1TwoFactorApiController located in C:/laragon/www/sprii/appHttpControllersApiV1TwoFactorApiController.php does not comply with psr-4 autoloading standard. Skipping.
Class IlluminateFoundationComposerScripts is not autoloadable, can not call post-autoload-dump script
> @php artisan package:discover --ansi
Fatal error: Uncaught Error: Class "IlluminateFoundationApplication" not found in C:laragonwwwspriibootstrapapp.php:14
Stack trace:
#0 C:laragonwwwspriiartisan(20): require_once()
#1 {main}
thrown in C:laragonwwwspriibootstrapapp.php on line 14
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
2
Answers
Remove your
compose.lock
file.Right-click on laragon icon in system tray and thick extensions:
Run
cmd
as administrator and then run these:The issue is that you are not using proper naming convention for PSR-4.
Your file structure is
appHttpControllersApiV1TwoFactorApiController.php
Namespace should be
AppHttpControllersApiV1TwoFactorApiController
✅Your current namespace is
AppHttpControllersapiv1TwoFactorApiController
which is wrong.Refactor the namespace and you won’t see this message.