0

I have been trying to use Google API in my 2.X CakePHP project for a couple of days now, and I seem not to be able to use it. The method I used to load it into my test server was installing it in local with composer (I changed my composer.json to include the library which looks like this).

{
"name": "cakephp/cakephp",
"description": "The CakePHP framework",
"type": "library",
"keywords": ["framework"],
"homepage": "http://cakephp.org",
"license": "MIT",
"authors": [
    {
        "name": "CakePHP Community",
        "homepage": "https://github.com/cakephp/cakephp/graphs       /contributors"
    }
],
"support": {
    "issues": "https://github.com/cakephp/cakephp/issues",
    "forum": "http://stackoverflow.com/tags/cakephp",
    "irc": "irc://irc.freenode.org/cakephp",
    "source": "https://github.com/cakephp/cakephp"
},
"require": {
    "php": ">=5.2.8",
    "ext-mcrypt": "*",
    "google/apiclient": "^2.0"
},
"require-dev": {
    "phpunit/phpunit": "3.7.*",
    "cakephp/debug_kit" : "2.2.*"
},
"bin": [
    "lib/Cake/Console/cake"
    ]
}

After that I uploaded my whole project using SFTP to my server, and even though I am running a simple script it would show the error "Google_Client class not found". My attemp looks like this:

dd(new Google_Client());
        exit();

My output is as follows:

'Class 'Google_Client' not found'
'/var/www/html/app/Controller/AgendaEventosController.php'

I have tried with composer dumpautoload and reuploading the composer autoload to my server via ftp and also tried to import the autoload like this: App::import("Vendor/Google/apiclient/src/Google","autoload.php"

Can anyone point a better approach to my problem? (also, for what it may be worth, my server's php version is 5.5.9 and my local enviroment -which I used to install the dependency- is 7.2, but I don't think this may be an issue)

As an aditional note: the README file states:

Finally, be sure to include the autoloader:

```php
require_once '/path/to/your-project/vendor/autoload.php';

It may also be worth mentioning I ran the composer install command in the root folder (not in the app folder).

But I am confused on where I should add this line, or even if I should add it, since CakePHP autoloader fires automatically (as fas as I know).

LuisE
  • 553
  • 3
  • 18
  • Possible duplicate of [Class 'Google\_Client' not found](https://stackoverflow.com/questions/44701156/class-google-client-not-found) – Sehdev Oct 26 '18 at 02:27
  • This might be because of you PHP version. Just update your PHP version. – Sehdev Oct 26 '18 at 02:28

0 Answers0