0
votes

I want sign up with google plus in codeigniter. I have include files which are required for the php script but I'm getting error

(( ! ) Fatal error: Cannot redeclare class Google_OAuth2 in D:\wamp\www\Surecash_back\application\libraries\google-plus-api-client-master\src\auth\Google_OAuth2.php on line 453)

1
You required them?, or did you autoload them?, might be doing both right now - Khoon
can you at least show your code here. - Beginner
use include_once() rather than include(). Problem solved. - Simba

1 Answers

0
votes

The error message tells you a very simple thing:

You are trying to load\include the same class file more then once (which results in re-declaring a class name of an already declared class).

The fastest way to check this, will be:

  1. If you are using an autoloader - check your autoloader folder tree for the existance of a file named Google_OAuth2.php
  2. Run a project-wide (all files in your project) search for the string "Google_OAuth2.php" and another search for "class Google_OAuth2", look for any duplicate include(), include_once() or require_once().

    (in phpStorm you click Cmd+Shift+F to open the path search, and in the options tab select "Whole project" in Scope.)

See where and if you are including\requiring\autoloading the Google_OAuth2 class file more then one time.

Finally, remove the duplicate.

Hope it helps a bit!