Unable to request file in symfony from google-api-php-client

I need to use google-api-php-client.To do this, I added the Google github repository to my composer.json

"repositories": [ { "type": "package", "package": { "name": "google/google-api-php-client", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/google/google-api-php-client.git", "reference": "master" }, "autoload" :{ "classmap": ["src"] } } } ] 

...

 "require" : { ... "google/google-api-php-client": "dev-master" } 

Everything is installed correctly, and I have the following directory structure:

 /vendor /google /google-api-php-client /examples /src /Google Client.php 

When I create an object in my controller, follow these steps:

 $client = new \Google_Client(); 

Found the way and class. However, I get the following error:

 ContextErrorException: Warning: require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory in /Users/etienne/Developpement/Ima-Tech/Clients/lesoptions/vendor/google/google-api-php-client/src/Google/Client.php line 18 

In my Client.php file, I have the following at the beginning of the file:

 require_once 'Google/Auth/AssertionCredentials.php'; 

If I changed the line to:

 require_once 'Auth/AssertionCredentials.php'; 

everything works fine for this inclusion. However, I do not want to change every require_once in every google-api-php-client project file. I'm sure there is a way to change the inclusion path or something, so I wonder how can I say that the Google namespace is the current directory?

Edit 1: I assume this could be because this project (google-api-php-client) does not use namespaces ...

+7
php symfony google-api
source share
1 answer

Try the following composer settings:

 "repositories": [ { "type": "vcs", "url": "https://github.com/google/google-api-php-client" } ], ... "require": { "google/apiclient": "dev-master" } 

Note. I use google/apiclient instead of google/google-api-php-client . This seems to work fine for me. I am on PHP 5.4.

I think the reason it doesn't work for you is because there is no include-path in your repository definition. If you look at the composer.json library, you will see that include-path points to the src directory.

+7
source share

All Articles