【问题标题】:LARAVEL: main(): Failed opening required 'vendor\autoload.php'LARAVEL:main():打开失败需要'vendor\autoload.php'
【发布时间】:2019-02-01 23:28:41
【问题描述】:

我关注了this documentation,我不断收到main(): Failed opening required 'vendor\autoload.php' 错误,我跑了composer install,但仍然遇到同样的错误。我正在使用 Laravel,我从控制器调用它..

namespace App\Http\Controllers;

require 'vendor/autoload.php';
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Google\Cloud\Speech\SpeechClient;
use Google\Cloud\Speech\StorageClient;
use App\Model\FilesModel;
use Illuminate\Support\Facades\DB;

class FilesController extends Controller
{

    private $project_id;
    private $speech;
    private $options;
    private $storage;

    public function __construct()
    {
        $storage = new StorageClient([
            'keyFile' => json_decode(file_get_contents(public_path() . '/key.json'), true)
        ]);
    ....

如何绕过这个问题?

【问题讨论】:

  • 您是否使用composer update 命令更新了您的作曲家?
  • 是的,我做到了,而且我还运行了composer dump-autoload,其中一个问题也提出了这一建议:stackoverflow.com/questions/41209349/…,但仍然是同样的问题。
  • 不需要在laravel中写require 'vendor/autoload.php';这一行,因为自动加载文件作为引导的一部分自动加载
  • 我会收到这个错误:"Class 'Google\Cloud\Speech\StorageClient' not found":stackoverflow.com/questions/44287349/…
  • 您将 Google 图书馆文件夹保存在哪里?在公共场所?

标签: php laravel composer-php autoload


【解决方案1】:

首先不需要这样做!因为它包含在所有页面中...
如果您坚持这样做,我认为问题在于自动加载文件的地址必须是:

require '../vendor/autoload.php';

【讨论】:

  • 酷,这解决了我的问题,除了我没有使用use Google\Cloud\Storage\StorageClient;,还有一个错字问题。
【解决方案2】:

使用 --no-scripts 运行 composer

composer update --no-scripts  

这将解决问题。我在 Mac 和 Linux 上试过这个。

【讨论】:

    【解决方案3】:

    我解决了删除“require '../vendor/autoload.php';”的问题来自控制器的句子并在两种环境(本地和服务器)中工作。我正在使用 Openpay 集成。

    这对我来说很难,因为我试图解决编辑路线或更新作曲家之类的问题。

    【讨论】:

      猜你喜欢
      • 2017-04-19
      • 2020-03-04
      • 2017-07-16
      • 2016-10-20
      • 2015-12-11
      • 2020-01-10
      • 2015-04-12
      • 2020-04-18
      • 2016-09-04
      相关资源
      最近更新 更多