Cannot require a file in Symfony from google-api-php-client

Viewed 2244

I need to use google-api-php-client.To do so, I added Google's 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 properly 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, doing the following :

$client = new \Google_Client();

The path and the class are found. 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 change the line to :

require_once 'Auth/AssertionCredentials.php';

everything works fine for that inclusion. However, I don't want to change each require_once in every file of the google-api-php-client project. I'm sure there is a way to change the inclusion path or something therefore I'm wondering how can I tell that the namespace "Google" is the current directory ?

Edit 1 : I'm guessing that this may be caused because this project (google-api-php-client) does not use namespaces...

1 Answers
Related