“意外 'StringLiteral'
"Unexpected 'StringLiteral'
我不知道为什么会出现这个错误.....任何人都可以帮助我吗?我尝试连接到 firestore。
<br/>
<?php
require_once 'vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
class GFireStore
{
protected $db;
protected $name;
public function __construct(string $collection)
{
$this->db = new FirestoreClient([
'projectId' -> 'final-fyp-project-1c86c'
]);
$this->name = $collection;
}
public function getDocument(string $name){
try{
if($this->db.collection($this->name)->document($name)->snapshot()->exists()){
return $this -> db.collection($this->name)->document($name)->snapshot()->data();
}else{
throw new Exception("Document are not exists");
}
}catch(Exception $exception){
return $exception ->getMessage();
}
}
}
PHP 关联数组的正确语法是 'projectId' => 'final-fyp-project-1c86c'
。 ->
语法保留用于访问对象的属性和方法。
我不知道为什么会出现这个错误.....任何人都可以帮助我吗?我尝试连接到 firestore。
<br/>
<?php
require_once 'vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
class GFireStore
{
protected $db;
protected $name;
public function __construct(string $collection)
{
$this->db = new FirestoreClient([
'projectId' -> 'final-fyp-project-1c86c'
]);
$this->name = $collection;
}
public function getDocument(string $name){
try{
if($this->db.collection($this->name)->document($name)->snapshot()->exists()){
return $this -> db.collection($this->name)->document($name)->snapshot()->data();
}else{
throw new Exception("Document are not exists");
}
}catch(Exception $exception){
return $exception ->getMessage();
}
}
}
PHP 关联数组的正确语法是 'projectId' => 'final-fyp-project-1c86c'
。 ->
语法保留用于访问对象的属性和方法。