問題描述
我正在將我網(wǎng)站的登錄系統(tǒng)從 LightOpenID 更新為 Google 的 Oauth 2.0.
I am updating my website's login system from LightOpenID to Google's Oauth 2.0.
當(dāng)我需要 Client.php 和 Service/Oauth2.php 時出現(xiàn)錯誤
When I require the Client.php and the Service/Oauth2.php I get an error
致命錯誤:在第 32 行的/home/myname/repos/website_current/lib/google-api-php-client/src/Google/Service/Oauth2.php 中找不到Google_Service"類
Fatal error: Class 'Google_Service' not found in /home/myname/repos/website_current/lib/google-api-php-client/src/Google/Service/Oauth2.php on line 32
我使用的代碼(來自我的 login.php 文件)看起來像這樣
The code I am using (from my login.php file) looks like this
require_once(dirname($_SERVER['DOCUMENT_ROOT']).'/lib/autoload.php');
require('Google/Client.php');
require('Google/Service/Oauth2.php');
echo "exit";
exit();
我在 PHP.ini(在/etc/php5/apache2/php.ini 中)添加了包含路徑
I have added the include path in the PHP.ini (in /etc/php5/apache2/php.ini) as
include_path = ".:/usr/local/lib/php:/home/myname/repos/website_current/lib/google-api-php-client/src"
所以它似乎我的 Oauth2.php 文件看不到任何其他包含,包括類Google_Service",它是Service.php"中的一個文件夾.
So its seems my Oauth2.php file can't see any of the other includes including the class 'Google_Service' which is one folder up in 'Service.php'.
我的文件夾結(jié)構(gòu)如下:
lib/
... autoload.php
... functions.php
... google-api-php-client/
... src/
... Google/ (etc etc)
public_html/
... login/
...login.php
我不知道為什么會發(fā)生這種情況.應(yīng)該可以看到包含路徑,并使用 phpinfo() 顯示為包含路徑;有人可以給我一些見解嗎?
I have no idea why this is occuring. The include path should be seen, and shows up as an included path using phpinfo(); Can someone please give me some insight?
推薦答案
確保您在任何其他 Googlerequire_once"行BEFORE之前添加該行.
Make sure you add the line BEFORE any other Google "require_once" lines.
require_once 'google-api-php-client/autoload.php';
我最后吃了它,它讓我撓了 10 分鐘.
I had it last and it had me scratching my head for a good 10 minutes.
這篇關(guān)于實(shí)現(xiàn) Oauth2 登錄,致命錯誤:找不到“Google_Service"類的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!