【发布时间】: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