What is the best way to develop locally in PHP and the Google datastore?
The dev_appserver.py docs say I can view local datastore entities, but there is no documentation on how to connect/write to this local datastore using PHP.
I can write to the local datastore emulator using:
// Start emulator: gcloud beta emulators datastore start --data-dir=_datastore
// Pointing this to dev_appserver's 'API server' doesn't work.
putenv('DATASTORE_EMULATOR_HOST=http://localhost:8081');
$datastore = $cloud->datastore();
But these entities do not show up in dev_appserver.py's local admin server at http://localhost:8000/datastore.
Even setting the dev_appserver's --datastore_path to be equal to the emulator's --data-dir does nothing.
Why are the datastore emulator and dev_appserver.py's datastore different? They share the same name and the docs refer to them interchangeably. This is frustrating.
Is this the correct way to do local datastore development? Is there a way to write to the local datastore and have the entities show up in the admin server viewer?
Google Cloud Datastore Emulator and dev_appserver.py have different underlying storage.
So the entities on datastore emulator cannot be shown in the admin server viewer.
see:
https://github.com/GoogleCloudPlatform/google-cloud-datastore/issues/21
Connecting to AppEngine datastore in development via Cloud Datastore API
There are maybe two way to connect to local datasotre (I'm not tried with php):
Use appengine-php-sdk for standard enviroment, start development server by dev_appserver.py, and view datastore from admin server viewer.
Use google/cloud library for php, and set DATASTORE_EMULATOR_HOST env variable.
Unfortunately there isn't viewer for emulator, so I'm developing cli tool to check datastore entities by GQL: https://github.com/nshmura/dsio
have u tried passing the environment variables to the php executable before including the libraries?
maybe try this:
#/bin/sh
export DATASTORE_EMULATOR_HOST=http://localhost:8081
dev_appserver.py ...
Related
Can I write (and read) files using PHP in my google cloud storage when Im not using a Google App Engine?
In other words, may I have my website running on another web hosting and use google cloud to store (and read in future) my JSON files only? the JSON files need to be written on runtime and by users.
you can store any files using any programming language like PHP to any cloud storage like google cloud storage or amazon s3, dropbox...etc
Checkout this documentation:
https://github.com/GoogleCloudPlatform/google-cloud-php#google-cloud-storage-ga
I am trying to connect my Local Development Site (using PHP) to Cloud Datastore, but unfortunately I do not know how to set up my code to reach the Datastore. I have tried the solution of tomwalder/php-gds, but I do not know, how to set up the code to work with my site. After the installation with composer, I do not know which file should be modified, there is no config.php in my directory. There are also no Google Documentation about Datastore for PHP.
I am open for any solution to connect the Datastore with my site.
Can you please give us a few tips, how to start the work?
I'd suggest taking a look at https://github.com/tomwalder/php-gds. Tom just released a version that connects natively to the datastore, which is faster than going via Cloud Datastore.
I am in a process of setting up Prestashop installation in a cluster of 3 GCE instances, managed by Kubernetes. I use Cloud SQL as DB and all seems to be running well, except, of course the images part, since prestashop in each pod uploads and shows images to/from it's local filesystem.
In App Engine I cloud use stream_context_set_default() and that would allow me to use "gs://mybucket" as a regular path. Is there a way to do that in Compute Engine? If it is possible, making Prestashop use Cloud Storage bucket can be done in 2 lines of code.
There is a StreamWrapper for Amazon S3 service that does exactly what I need: http://hiousi.tumblr.com/post/94824087894/prestashop-images-hosted-on-amazon-s3
But I would like to use Cloud Storage.
The source code for the stream wrapper can be downloaded at https://github.com/GoogleCloudPlatform/appengine-php-sdk/tree/master/google/appengine/ext/cloud_storage_streams.
It has a couple of dependencies on other GAE APIs such as App Identity & Urlfetch. They may need to be stubbed out or replaced by equivalent services on GCE.
i have created a PHP StreamWrapper for Google Compute Engine, if you're still interested. Here is the link to my adapted version.
https://github.com/jimyaghi/GCECloudStorageStreamWrapper
Sorry it's not more friendly, but it's a good useful bit of work. i'm using it and it works great.
I'm trying to deploy Question2Answer (Q2A) by following this official install guide - where we need to set up
A web server to push Q2A source code to - uploading application folder to App Engine instance matched with this.
A MySQL database and the according log-in account - this is matched by creating and configuring a Cloud SQL instance to work with our app engine instance.
Though I failed to get Q2A run on Google's cloud - as browing the deployed web I get the error as below snapshot.
How would you guys get it deployed successfully?
p.s.
Steps I have made to Q2A's PHP source code
Entering MySQL database access credentials (by following this guide)
Adding app.yaml file so as Google App Engine SDK would deploy Q2A application
The Q2A source code folder I'm working with is as below.
You just need to remove the root password and leave it like this:
define('QA_MYSQL_PASSWORD', '');
You can find at the documentation that "when you connect from App Engine, you can use the root user and no password"
Hope it helps.
How to use another database for Google App engine than the datastore. And if it could be possible to access it with php(quercus).
Not in practical terms. Datastore is the only supported database at the moment.
You could have a database on another server and access it via RPC (REST, WebService), but this would not be an integrated approach and would add more work to the project. For example you could set up a MySql server somewhere and use phprestsql to setup a REST interface and then acces it from GAE.
#Peter Knego
i am also looking for same. I want to host my java web application on GAE and databse on different Server(Godaddy).
Google data store is free for only 6 months, So i would like to use database of different hosting(goDaddy). So is it possibe??
I am able to use database of my hosting(goDaddy) from my local system but when i upload my application to GAE that it doesn't work. I know it is possible in case of other servers but what about GAE.