1

我一直無法找到Google Could Datastore的PHP API的任何文檔。我正在嘗試將NoSQL(MongoDB數據庫)網站遷移到Google App Engine--目前,雲數據存儲似乎是最佳選擇。我能找到的唯一文檔是用於Node.js,Python和Java。Google Cloud Datastore的PHP API

https://developers.google.com/datastore/docs/getstarted/

+1

https://developers.google.com/appengine/docs/php/gettingstarted/introduction? – 2013-07-05 03:14:14

+0

是的,我看了一下 - 但沒有API參考:Stuart說很快就會有一些東西可用:https://twitter.com/TheFuriousAnt/status/353103115647598592 –

+0

同時,您可以使用API​​客戶端:https:/ /code.google.com/p/google-api-php-client/ – Mars

回答

0

Google的official PHP client library現在是GA。

您可以用作曲安裝:

composer require google/cloud 

使用它是如此的簡單,包括它,初始化客戶端爲您的項目,然後執行您的操作:

# Includes the autoloader for libraries installed with composer 
require __DIR__ . '/vendor/autoload.php'; 

# Imports the Google Cloud client library 
use Google\Cloud\Datastore\DatastoreClient; 

# Your Google Cloud Platform project ID 
$projectId = 'YOUR_PROJECT_ID'; 

# Instantiates a client 
$datastore = new DatastoreClient([ 
    'projectId' => $projectId 
]); 

# The kind for the new entity 
$kind = 'Task'; 

# The name/ID for the new entity 
$name = 'sampletask1'; 

# The Cloud Datastore key for the new entity 
$taskKey = $datastore->key($kind, $name); 

# Prepares the new entity 
$task = $datastore->entity($taskKey, ['description' => 'Buy milk']); 

# Saves the entity 
$datastore->upsert($task); 

echo 'Saved ' . $task->key() . ': ' . $task['description'] . PHP_EOL; 

上的官方客戶端庫是Cloud Datastore使用最廣泛的PHP庫,目前仍在使用和運作,它是https://github.com/tomwalder/php-gds

從版本開始3,PHP GDS支持v1 REST API,這意味着您可以在任何計算服務上的App Engine之外使用它。

相關問題