无法让 Laravel Sheets 扩展工作

Sam*_*rai 2 google-sheets laravel

我是 Laravel 的新手,正在尝试使用此扩展程序:https : //github.com/kawax/laravel-google-sheet从 Google 电子表格中读取数据。

但是,文档并未详细说明每个步骤。

我意识到我必须像这样将提供者放在 app.php 中:'Sheets' => Revolution\Google\Sheets\Sheets::class,,并在我的 app.php 中像这样Sheets' => Revolution\Google\Sheets\Sheets::class,在文档中放置 一个别名。希望这是对的......?

然后,我尝试从第一Laravel例如README.md

use Sheets; // I had to precede with "\"
use Google; // I had to precede with "\"

Sheets::setService(Google::make('sheets'));
Sheets::spreadsheet('myspreadsheetid');
Run Code Online (Sandbox Code Playgroud)

但是我收到这个错误:

Non-static method Revolution\Google\Sheets\Sheets::setService() should not be called statically
Run Code Online (Sandbox Code Playgroud)

Ste*_*fan 5

我对图书馆不熟悉。

但是,看起来Sheets您调用静态setService()方法的类不是实际 Sheets 实例的外观。

尝试

use Revolution\Google\Sheets\Facades\Sheets;
Run Code Online (Sandbox Code Playgroud)

代替

use \Sheets;
Run Code Online (Sandbox Code Playgroud)