简体   繁体   中英

Fatal error: require(): Failed opening required 'vendor/autoload.php' in Laravel project/Serpwow API

I know there are already a lot of topics and solutions about this error, but nothing seems to work for me.

So, I'm having a Laravel project created with composer. To run the project I use the "php artisan serve" command. In my project, I'm using the SerpWoW API, an easy to use API for Google images etc. since yesterday, installed with composter (composer require serpwow/google-search-results). But since then I'm having trouble with vendor/autoload.php.

In one of SerpWoW's config files, there's a line:

require "vendor/autoload.php";

Like this, I'm able to run the serve command and to start the project. Unfortunately, my views (.blade.php files) are giving the error: Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\\xampp\\php\\PEAR') in (path to that config file)

I then changed

require "vendor/autoload.php"; 

to

require "../vendor/autoload.php";

and my views came back. Problem solved I thought. But now I'm getting the error when I try to run the serve command to run my project. Same error pointing to same file and so unable to start my project. When I reverse my solution I'm able again to start my project but my views are giving the error again (I know, it's complicated). What I'm doing now is starting my project with original path, then change the path in the file, save it and so I'm able to see my views.

I've already run composer install and composer update for a few times in my project directory but that didn't help. Hope someone knows a solution for this.

It looks like the package solved the issue in the master branch, see the comparison between the current 0.2.4 and master :

- require "vendor/autoload.php";
+ require __DIR__ . '/../../../vendor/autoload.php';

Since you should not modify any files in the vendor folder, you could instead require the latest development version until this change is tagged with a proper version number or maybe ask the maintainer to tag a release with this change:

composer require serpwow/google-search-results:"@dev-master"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM