【发布时间】:2026-01-20 16:15:02
【问题描述】:
RequestWrapper.php 第 257 行中的 ServiceException: count():参数必须是数组或者实现了Countable的对象
以下是我在 laravel 5 中编写的代码。
use Google\Cloud\BigQuery\BigQueryClient;
use Google\Cloud\Core\ServiceBuilder;
public function __construct()
{
$this->getservicekey = env('GOOGLE_APPLICATION_CREDENTIALS');
}
//Function where i write code for getting data from gcloud bigquery
public function index()
{
// Authenticate using Service Account Key
$cloud = new ServiceBuilder([
'keyFilePath' => $this->getservicekey
]);
$bigQuery = $cloud->bigQuery();
$query = 'SELECT * FROM [publicdata:wikipedia.samples] limit 10';
$queryJobConfig = $bigQuery->query($query);
$queryResults = $bigQuery->runQuery($queryJobConfig);
foreach ($queryResults->rows() as $row) {
print_r($row);
}
}
下面是详细显示错误的图像文件。
【问题讨论】:
标签: php laravel-5.2 google-bigquery