You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More details and recommended upgrade paths to come. Along with better gRPC support for outside App Engine.
31
+
## New in Version 5.0 ##
32
+
33
+
**As of version 5 (May 2021), this library provides support for**
34
+
35
+
* PHP 7 second-generation App Engine runtimes - using the REST API by default
36
+
* PHP 7 "anywhere" (e.g. Google Compute Engine, Cloud Run, GKE) - using REST or gRPC
17
37
18
-
## Datastore API Turn Down, Sep 2016 ##
38
+
**Key features removed from version 5 onwards**
19
39
20
-
Google turned down the older versions of the REST API on September 30th, 2016. Version v1beta1 and v1beta2 are no longer available.
40
+
* PHP 5 support
41
+
* Support for the legacy "Protocol Buffer" API built into first-generation App Engine runtimes
21
42
22
-
* If you are using this library on App Engine, and using the default `Protobuf` gateway then NO CHANGES ARE NEEDED. Version 2.x or 3.x are both supported.
23
-
* If you are using this library anywhere else, like Compute Engine, and you are using the `GoogleAPIClient` gateway (version 2.x), then you will need to upgrade to version 3.x
43
+
If you need to continue running applications on that infrastructure, stick to version 4.x or earlier.
24
44
25
45
## Table of Contents ##
26
46
27
47
*[Examples](#examples)
28
-
*[New in version 4.0](#new-in-version-40)
29
-
*[Changes in version 3.0](#changes-in-version-30): [Datastore REST API v1 (Sep 2016)](#using-the-datastore-rest-api-v1-sep-2016)
30
-
*[Changes in version 2.0](#changes-in-version-20)
31
48
*[Getting Started](#getting-started) including installation with Composer and setup for GDS Emulator
32
49
*[Defining Your Model](#defining-your-model)
33
50
*[Creating Records](#creating-records)
@@ -41,6 +58,33 @@ Google turned down the older versions of the REST API on September 30th, 2016. V
41
58
*[Unit Tests](#unit-tests)
42
59
*[Footnotes](#footnotes)
43
60
61
+
## Using the REST API (default from 5.0) ##
62
+
63
+
As of PHP-GDS version 5, the REST API Gateway is the default.
64
+
65
+
It will attempt to auto-detect your Google Project ID - and usually the Google auth library will use the default application credentials.
66
+
67
+
You might need to set an environment variable with the path to your JSON credentials file first, usually if you're running outside of App Engine or Google Compute Engine.
$obj_book_store = new GDS\Store('Book', new \GDS\Gateway\RESTv1('my-project-id'));
74
+
```
75
+
76
+
You can find out more about the auth system here: [Google Auth Library for PHP](https://github.com/google/google-auth-library-php)
77
+
78
+
You can download a service account JSON file from the Google Cloud Console `API Manager > Credentials`.
79
+
80
+
## Firestore in Datastore Mode ##
81
+
82
+
If you are using PHP-GDS version 4 or earlier, and Firestore in Datastore mode from App Engine standard (first generation), you may run into `Internal Error`s from the `Protobuf` gateway.
83
+
84
+
You can resolve this by using the `RESTv1` Gateway & APIs. [See here for basic guidance](#using-the-datastore-rest-api-v1-sep-2016)
85
+
86
+
More details and recommended upgrade paths to come. Along with better gRPC support for outside App Engine.
87
+
44
88
## Examples ##
45
89
46
90
I find examples a great way to decide if I want to even try out a library, so here's a couple for you.
@@ -79,14 +123,12 @@ foreach($obj_store->fetchAll() as $obj_book) {
79
123
### More about the Examples ###
80
124
81
125
These initial examples assume you are either running a Google AppEngine application or in a local AppEngine dev environment.
82
-
In both of these cases, we can auto detect the **dataset** and use the default ***Protocol Buffer Gateway***.
126
+
In both of these cases, we can auto detect the **dataset**.
83
127
84
128
We use a `GDS\Store` to read and write `GDS\Entity` objects to and from Datastore.
85
129
86
130
These examples use the generic `GDS\Entity` class with a dynamic Schema. See [Defining Your Model](#defining-your-model) below for more details on custom Schemas and indexed fields.
87
131
88
-
Check out the [examples](examples/) folder for many more and fuller code samples.
$obj_book_store = new GDS\Store('Book', new \GDS\Gateway\RESTv1(PROJECT_ID));
124
-
```
125
-
126
-
You can find out more about the auth system here: [Google Auth Library for PHP](https://github.com/google/google-auth-library-php)
127
-
128
-
You can download a service account JSON file from the Google Cloud Console `API Manager > Credentials`.
129
-
130
-
## Changes in Version 2.0 ##
131
-
132
-
Features in 2.0 included
133
-
***Faster** - use of Google Protocol Buffer allows faster, low-level access to Datastore
134
-
***Easier to use** - sensible defaults and auto-detection for AppEngine environments
135
-
***Less dependencies** - no need for the Google PHP API Client, unless running remote or from non-AppEngine environments
136
-
***Local development** - Using the Protocol Buffers allows us to access the development server Datastore
137
-
***Local GQL support** - By default, the local development server does not support GQL. I've included a basic GQL parser that makes this work.
138
-
***Data Migrations** - leverage multiple Gateways to ship data between local and live Datastore
139
-
***Contention Exceptions** - standardised Exception for handling Datastore transaction contention
140
-
***Unit tests**
141
-
* Optional drop-in JSON API Gateway for remote or non-AppEngine environments (this was the only Gateway in 1.x)
142
-
143
-
### Backwards Compatibility ###
144
-
145
-
#### v3 over v2 ####
146
-
147
-
The REST API v1 implementation now follows the same datetime response formats at the ProtoBuf API. (Y-m-d H:i:s).
148
-
149
-
#### v2 over v1 ####
150
-
151
-
The library is *almost* fully backwards compatible. And in fact, the main operations of the `GDS\Store` class are identical.
152
-
153
-
There is one BC-break in 2.0 - the re-ordering of construction parameters for the `GDS\Store` class.
154
-
155
-
`GDS\Store::__construct(<Kind or Schema>, <Gateway>)`
156
-
157
-
instead of
158
-
159
-
`GDS\Store::__construct(<Gateway>, <Kind or Schema>)`
160
-
161
-
This is because the Gateway is now optional, and has a sensible, automated, default - the new Protocol Buffer implementation.
162
-
163
157
## Getting Started ##
164
158
165
159
Are you sitting comfortably? Before we begin, you will need:
@@ -172,22 +166,17 @@ If you want to use the JSON API from remote or non-App Engine environments, you
172
166
173
167
### Composer, Dependencies ###
174
168
175
-
To install using Composer, use this require line
176
-
177
-
`"tomwalder/php-gds": "v4.*"`
178
-
179
-
For older series
180
-
181
-
`"tomwalder/php-gds": "v3.*"`
169
+
To install using Composer
182
170
183
-
`"tomwalder/php-gds": "v2.*"`
184
-
185
-
and for bleeding-edge features, dev-master
171
+
```bash
172
+
composer require "tomwalder/php-gds:^5.0"
173
+
```
186
174
187
-
`"tomwalder/php-gds": "dev-master"`
175
+
### Use with the Datastore Emulator ###
176
+
Local development is supported using the REST Gateway and the Datastore Emulator.
188
177
189
-
### Use with the GDS emulator ###
190
-
If you want to use it with the GDS emulator make sure the environment variable `DATASTORE_EMULATOR_HOST` is set with the host, for example `localhost:8081`
0 commit comments