如何在Google云平台上使用Firestore正确部署PHP应用程序?
我正在谷歌云平台上使用云Firestore建立一个PHP应用程序 部署到App Engine后,我看到“新建FirestoreClient();”无法工作,但相同的代码通常在本地主机上运行。我怎样才能解决这个问题 守则: index.php如何在Google云平台上使用Firestore正确部署PHP应用程序?,php,google-app-engine,google-cloud-platform,google-cloud-firestore,google-app-engine-php,Php,Google App Engine,Google Cloud Platform,Google Cloud Firestore,Google App Engine Php,我正在谷歌云平台上使用云Firestore建立一个PHP应用程序 部署到App Engine后,我看到“新建FirestoreClient();”无法工作,但相同的代码通常在本地主机上运行。我怎样才能解决这个问题 守则: index.php <?php require_once 'vendor/autoload.php'; use Google\Cloud\Firestore\FirestoreClient; echo "Hello Firestore"; $firestore =
<?php
require_once 'vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
echo "Hello Firestore";
$firestore = new FirestoreClient();
$collectionReference = $firestore->collection('boards');
$documentReference = $collectionReference->document("b-1");
$snapshot = $documentReference->snapshot();
$data = $snapshot->data();
var_dump($data);
echo "Goodbye Firestore";
?>
谷歌云平台日志
GET 200 385 B 1,3 s Chrome 74 / I GET 200 385 B 1,3 s Chrome 74
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /tmp/google-config/nginx.conf:3
A GET 200 107,58 KiB 2 ms Chrome 74 /images/logo.png A GET 200 107,58 KiB 2 ms Chrome 74
composer.json
{
"name": "projects/plzwork",
"description": "i don't know...",
"type": "project",
"license": "Apache-2.0",
"require": {
"google/cloud": "^0.101.0",
"grpc/grpc": "^1.19"
}
}
使用localhost进行输出
你好,Firestore
数组(4){[“headline”]=>string(1)“b”[“线程数量”]=>int(1)
[“description”]=>string(22)“洪水和其他”
[“内容类型”]=>字符串(7)“默认值”}
再见,消防商店
使用谷歌云平台输出
你好,Firestore
我认为您可能缺少一个
php.ini
文件来启用云Firestore所需的grpc
扩展:
php.ini
extension=grpc.so
在应用程序中包含此文件。查看以下文档:
我认为您可能缺少一个
php.ini
文件来启用云Firestore所需的grpc
扩展:
php.ini
extension=grpc.so
在应用程序中包含此文件。查看以下文档:
由于执行在“Hello Firestore”输出后停止,因此似乎发生了错误。有关更多详细信息,请查看云控制台中的应用程序日志。一旦发现错误,如果您自己无法修复,请在本问题中分享。由于执行在“Hello Firestore”输出后停止,因此似乎发生了错误。有关更多详细信息,请查看云控制台中的应用程序日志。一旦发现错误,如果您自己无法修复,请在这个问题中分享它。现在我在localhost上看到身份验证警告,而在gcloud上没有任何新内容(您是否收到任何错误?请查看我在上面和一段时间后显示的日志,仅出于某些原因-标题中logo.png的响应204。更多要验证的是项目ID。您可能还需要删除行
putenv(“GCLOUD\u project=moondepth”)
。moondepth
是正确的项目ID吗?项目是否有boards/b-1
文档?项目ID是“moondepth”,文档存在,但当我将ID更改为“sdgsadwgf”时,在本地主机上我会得到“Hello Firestore\n NULL\n再见Firestore\n”,在GCloud上我会得到“Hello Firestore\n”如果没有错误,我在localhost上看到身份验证警告,在gcloud上没有任何新内容(您收到任何错误吗?出于某种原因,请查看日志,我在上面和一段时间后显示的信息性日志-标题中logo.png的响应204。更多要验证的是项目ID。您可能还需要删除行putenv(“GCLOUD\u PROJECT=moondepth”);
是否是正确的项目ID,项目是否有boards/b-1
文档?项目ID为“moondepth”,文档存在,但当我将ID更改为“sdgsadwgf”时,在本地主机上我会得到“Hello Firestore\n NULL\n再见Firestore\n”,在GCLOUD上我会得到“Hello Firestore\n”“没有错误