I'm really new to the whole GCP platform and I'm trying to create my first web app, specifically in PHP. I've went through every thread, tutorials, etc. but they are too advance from me.
Could someone please let me know what are the most basic steps for querying a data in Cloud datastore using PHP from APP Engine?
This is my setup: In my Datastore, there's 1 entry which basically has 2 properties called name and address, a PHP file on APP Engine that would just query the datastore.
I've enabled Datastore API access for my app. I've also deployed it. But I can't make it to work.
This is my view.php file:
<?php
use Google\Cloud\Datastore\DatastoreClient;
# Your Google Cloud Platform project ID
$projectId = '<my project id>';
# Instantiates a client
$datastore = new DatastoreClient(['projectId' => $projectId]);
$query = $datastore->query()
->kind('person');
$result = $datastore->runQuery($query);
foreach ($result as $entity) {
echo 'Entity found: ' . $entity['name'] . PHP_EOL;
}
?>
note: I deployed my app with these 3 files:
- app.yaml
- index.php (hello world page)
- view.php
app.yaml content:
runtime: php55
api_version: 1
handlers:
- url: /
script: index.php
- url: /index\.html
script: index.php
- url: /view
script: view.php
- url: /view\.html
script: view.php
- url: /.*
script: not_found.php
app.yamlfile? - Parag JadhavStackdriver Loggingalso, it is very helpful sometimes - Parag Jadhav