Without an internet connection (due to traveling, limited Internet), any request to the local datastore emulator will fail because the google-cloud-php client library is attempting to contact www.googleapis.com.
I spoke to the datastore emulator team, and they confirmed they designed the Cloud Datastore Emulator to be usable without an internet connection. They requested I file this as a bug in the google-cloud-php client library.
Using version ^0.40.0 for google/cloud
Simple query produces the following without an internet connection:
PHP Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException: cURL error 6: Could not resolve host: www.googleapis.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in /home/dev/source/composer-google-cloud/vendor/google/cloud/src/Core/RequestWrapper.php:253 Stack trace:
0 /home/dev/source/composer-google-cloud/vendor/google/cloud/src/Core/RequestWrapper.php(158): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(Google\Cloud\Core\Exception\ServiceException))
1 /home/dev/source/composer-google-cloud/vendor/google/cloud/src/Core/RestTrait.php(95): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)
2 /home/dev/source/composer-google-cloud/vendor/google/cloud/src/Datastore/Connection/Rest.php(105): Google\Cloud\Datastore\Connection\Rest->send('projects', 'runQuery', Array)
3 /home/dev/source/composer-google-cloud/vendor/google/cloud/src/Core/Iterator/PageIteratorTrait.php(233): Google\Cloud\Datastore\Connection\Rest->runQuery(Array)
4 /home/dev/source/composer- in /home/dev/source/composer-google-cloud/vendor/google/cloud/src/Core/RequestWrapper.php on line 253
Confirmed I can directly access the emulator via curl without an Internet connection:
$ curl http://192.168.56.1:8081/ Ok
该提问来源于开源项目:googleapis/google-cloud-php