Как правильно развернуть приложение PHP с Firestore на Google Cloud Platform? - PullRequest
0 голосов
/ 13 мая 2019

Я настраиваю PHP-приложение с Cloud Firestore на Google Cloud Platform на основе https://github.com/googleapis/google-cloud-php-firestore.

После развертывания на App Engine я вижу, что " new FirestoreClient (); " не работает, но тот же код нормально работает на localhost, Как я могу это исправить?

код:

index.php

<?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";
?>

app.yaml

runtime: php72

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /images
  static_dir: images

- url: /stylesheets
  static_dir: stylesheets

Журналы Google Cloude Platform

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

array (4) {["headline"] => string (1) "b" ["amount_of_threads"] => int (1) ["description"] => string (22) "Потоп и ничего больше" ["content_type"] => string (7) "default"}

Goodbye Firestore

Вывод с Google Cloud Platform

Привет Firestore

Просмотр базы данных

1 Ответ

1 голос
/ 13 мая 2019

Я думаю, вам может не хватать файла php.ini для включения расширения grpc, которое требуется Cloud Firestore:

php.ini

extension=grpc.so

Включите этот файл в ваше приложение. Проверьте эти документы:

Кроме того, вы упомянули, что не видели ошибок в своих журналах. Ошибки могут быть зарегистрированы в разных файлах, которые не отображаются по умолчанию. Вот как их можно посмотреть в консоли:

enter image description here

...