Sure, I could fetch all entities and count how many there were, but this was the most expensive and least efficient way of going about it, so it wasn't even an option.
I had some pretty wild ideas about how this could be achieved efficiently - including keeping track of how many entities of the same kind were created and looking that up as needed. Turned out that was exactly what Google was doing already! ...with the NDB Administration queries.
It was possible to issue a standard GQL query like 'select * from __Stat_Kind__' and get all sorts of statistics on entity kinds, including the total count!
So I figured that since this was looking up what appeared to as a standard entity in the Datastore, I could make this work with php-gds. So I put together some simple test code. Since the __Stat_Kind__ entity kind was using other entity kinds as key names, I could look up whatever entity kind I wanted stats for easily...
It gave me results!
I was on the right track and I could get the total count of entities of the same kind with this query - all I had to do was get the value of the 'count' property from the returned entity. It was so simple!
From here it was a matter of writing code that used the fetchPage() function on the Store class and I was done. The actual pagination code after having the total count of entities was more or less trivial, so I won't cover that part here.
There was a small catch to testing this in the local dev server. Unlike the production Datastore, the local Datastore does not automatically generate entity statistics. These needed to be generated manually via the dev server console.