我是新来Symfony的。我需要在Symfony 2项目中使用一个好的also /google-spreadsheet-bundle(也叫WkGoogleSpreadsheetBundle)。在捆绑包的usage部分中有如下示例:
“服务wk_google_spreadsheet提供了与Google Spreadsheet PHP客户端的直接交互。您可以直接在服务上调用客户端的所有方法”。
所以我写了这段代码:
$service = $container->get('wk_google_spreadsheet');
$service->getSpreadsheets();
$service->getSpreadsheetById();
$service->getListFeed();
$service->getCellFeed();但我不知道该怎么做,因为首先我需要知道什么是变量$container。
当我把类似这样的东西放入Controller中时:
use Google_Client;
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;
use Google\Spreadsheet\SpreadsheetService;然后在行动中:
public function importAction(Request $request, $id)
{
$service = $container->get('wk_google_spreadsheet');
$entity = new Settlement();
$form = $this->createCreateForm($entity, $id);
...
}我有错误“通知:未定义的变量:容器。”
那么,我将在哪里以及如何定义$container。
发布于 2016-04-27 05:18:47
好的。我想我该怎么做。包含$service的代码行应该如下所示:
$service = $this->container->get('wk_google_spreadsheet');不是这样的:
$service = $container->get('wk_google_spreadsheet');但是我仍然有一个关于线条的问题:
$service->getSpreadsheets();
$service->getSpreadsheetById();
$service->getListFeed();
$service->getCellFeed();在第一个问题上,我有一个错误,比如:字符串无法被解析为XML
问题出在哪里?感谢您的帮助。
https://stackoverflow.com/questions/36869796
复制相似问题