Alex Kerr
Alex Kerr

Reputation: 1080

How to install Google API PHP Client with Composer? (to use with php-gds lib and Google App Engine)

I'm trying to install the Google API PHP Client using Composer https://github.com/google/google-api-php-client#composer I've never used Composer before, but I've downloaded and installed it (on Win 7).

I wasn't sure what to do next or what to put where, if anything. Without downloading the Google API Client, I just went into my PHP project's folder on the command line and entered:

composer require google/apiclient:^2.0.0@RC

which did some stuff and then threw back:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package google/apiclient could not be found in any version,
there may be a typo in the package name.

I also tried manually downloading the API Client package (latest 2.0RC6 release), unpacking it into my PHP project dir, CD into that and doing the same composer command again. Got same error.

I'm building a PHP project on Google App Engine using the excellent PHP-GDS library to access Cloud Datastore and need the API Client to use the Gateway JSON API interface working (so I can try projection queries). Without that I'm getting the error Fatal error: Class 'Google_Client' not found in GDS\Gateway\GoogleAPIClient.php on line 87

I haven't used Composer to install php-gds. My understanding is that Composer will only bring the needed .php files from a lib into my project so unneeded ones are not uploaded to App Engine or included at run-time?

Anyway, any help much appreciated! (especially explicit steps of what to do!)

Many thanks.

Upvotes: 1

Views: 7320

Answers (1)

Nate Bunney
Nate Bunney

Reputation: 2520

Simply install with

composer require google/apiclient

Google is terrible at updating their docs.

Upvotes: 4

Related Questions