Google just announced support for a PHP runtime for App Engine. I have an app developed using the Java runtime which utilizes the native App Engine datastore. It currently f
you need to enable Google Cloud datastore for your project, see https://developers.google.com/datastore/docs/activate#google_cloud_datastore_for_an_existing_app_engine_application
note: you do not need compute engine enabled
make sure that on the admin console the application settings cloud integration section shows 'The project was created successfully. See the Basics section for more details.'
Follow the instructions on how to get and use the Google API client library on AppEngine https://gaeforphp-blog.appspot.com/2013/08/06/using-the-google-apis-client-library-for-php-with-app-engine/
See the attached working example for looking up Decoded entity key: Guestbook: name=default_guestbook > Greeting: id=5733953138851840
setApplicationName("your_app_id");
$key = file_get_contents('storage/your-hashed-keyid-privatekey.p12');
$client->setAssertionCredentials(
new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/datastore'),
$key)
);
$datastore = new Google_DatastoreService($client);
$lookup = new Google_LookupRequest();
$path1 = new Google_KeyPathElement();
$path1->setKind('Guestbook');
$path1->setName('default_guestbook');
$path2 = new Google_KeyPathElement();
$path2->setKind('Greeting');
# this is just an example check a real entity id in your datastore
# if you do not have ancestor entity you only need one (path1) element
$path2->setId('5733953138851840');
$key = new Google_Key();
$key->setPath([$path1,$path2]);
$keyArray = array();
$keyArray[] = $key;
$lookup->setKeys($keyArray);
if(array_key_exists('catchError', $_GET)){
try{
$result = $datastore->datasets->lookup('your_project_name', $lookup);
var_dump($result);
}
catch(Google_ServiceException $e){
echo "";
var_dump($e);
echo "
";
}
}
else{
$result = $datastore->datasets->lookup('your_project_name', $lookup);
var_dump($result);
}